#include <bits/stdc++.h> using namespace std; int main() { int a,b,c,d,res; while(cin>>a>>b>>c>>d) { if(a==0 and b==0 and c==0 and d==0) break; res=1080; res += (a > b) ? (a - b) * 9 : (a - b + 40) * 9; res += (c > b) ? (c - b) * 9 : (c - b + 40) * 9; res += (c > d) ? (c - d) * 9 : (c - d + 40) * 9; //res+=a>b? a-b*9 :((a-b)+40)*9; cout<<res<<endl; } return 0; }