#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  vector<int> times;
  times.push_back(A);
  times.push_back(B);
  times.push_back(C);
  times.push_back(D);
  times.push_back(E);
  int res = 0;
  vector<int> xs;
  for (size_t i = 0; i < times.size(); ++i) {
    res += times[i];
    int count = res;
    while (count % 10 != 0) {
      count += 1;
      xs.push_back(res - count);
    }
    res = count;
  }
  int mn = INT_MAX;
  for (auto p : xs)
    if (p < mn) mn = p;
  cout << res + mn << endl;
  return 0;
}
