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

int main() {
int A,B,C,D,E,a,b,c,d,e,sum=0,div=10;
  vector<int> num(5);
  vector<int> sumnum(5);
   cin >> A >> B >> C >> D >> E;

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

int main() {
int A,B,C,D,E,a,b,c,d,e,sum=0,div=10;
  vector<int> num(5);
  vector<int> sumnum(5);
   cin >> A >> B >> C >> D >> E;

   a = A % 10;
   b = B % 10;
   c = C % 10;
   d = D % 10;
   e = E % 10;
   num = {a,b,c,d,e};
   sumnum = {A,B,C,D,E};
  for(int i=0;i<5;i++){
   if(num[i] ==0){
    sum = sum +sumnum[i];
   }
   else{
     if( num[i] < div ){
      div = num[i];
          if( sumnum[i] > 10 ){ sum = sum + sumnum[i]-num[i]+10;
          }
          else if(num[i] < 10){
          sum = sum +10;
          }
     }
     else{
      sum = sum +sumnum[i] + 10 -num[i];
     }
   }

  }

 if(div ==10){
  sum = sum ;
 }
 else{

 sum = sum + div -10;
}
 cout << sum << endl;
}
