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