#include<bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c,d,e;
  cin >>a >>b >>c >>d >>e;
  int ans=0;
  int arest = 10 - a%10;
  int brest = 10 - b%10;
  int crest = 10 - c%10;
  int drest = 10 - d%10;
  int erest = 10 - e%10;
  int extra = max(arest,max(brest,max(crest,mac(drest,erest))));
  ans = a+b+c+d+e+arest+brest+crest+drest+erest-extra;
  cout<<ans<<endl;
}