#include<bits/stdc++.h>
using namespace std;
int main(){
int k,w,s,e,ans;
while(cin>>k>>w>>s>>e){
ans=20;
if(k>2) ans+=(k-2)*5;
ans+=(w/2)*5;
if(s<=18&&e>=19) ans+=185;
if(s<=19&&e>=20) ans+=195;
if(s<=20&&e>=21) ans+=205;
if(s<=21&&e>=22) ans+=215;
if(s<=22&&e>=23) ans+=225;
cout<<ans<<endl;
}
return 0;
}