#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};
  int best_time = 1e9;
  do {
    int now_time = 0;
    for (int i = 0; i < n; i++) {
      while (now_time % 10 != 0) {
        now_time++;
      }
      now_time += time[i];
    }
    best_time = min(now_time, best_time);
  } while (next_permutation(time.begin(), time.end()));
  cout << best_time << endl;
  return 0;
}
