#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e;
  int N = 5;
  cin >> a >> b >> c >> d >> e;
  vector<int> Time = {a, b, c, d, e};
  vector<int> index = {0, 1, 2, 3, 4};
  int BestTime = 99999999;
  do {
    int NowTime = 0;
    for (int i = 0; i < N; i++) {
      NowTime = Time[i];
      while (NowTime % 10 != 0) NowTime++;
      NowTime += Time[index[i]];
    }
    BestTime = min(BestTime, NowTime);
  } while (next_permutation(index.begin(), index.end()));
  cout << BestTime << endl;
  return 0;
}
