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

int main() {
  vector<int> A(5);
  cin >> A.at(0) >> A.at(1) >> A.at(2) >> A.at(3) >> A.at(4);
  vector<int> index = {0, 1, 2, 3, 4};
  int besttime = 1000000000;
  do {
    int nowtime = 0;
    for (i = 0; i < 5; i++) {
      while(nowtime %  10 != 0) nowtime++;
      nowtime += A.at(index.at(i));
    }
    besttime = min(besttime, nowtime);
  } while (next_permutation(index.begin(), index.end()));
  cout << besttime << endl;
  return 0;
}