#include <bits/stdc++.h>
using namespace std;
int main()
{
  vector<int> v(5);
  int sum = 0;
  for(int i=0;i<5;i++){
    cin >> v[i];
    sum += v[i];
    v[i] %= 10;
    if(v[i] != 0) v[i] = 10 - v[i];
  }
  
  sort(v.begin(),v.end());
  sum += v[0] + v[1] + v[2] + v[3];
  
  cout << sum << endl;
}
