#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
signed main() {
  long long a[5];
  for (long long i = 0; i < (5); i++) {
    cin >> a[i];
  }
  long long sum = 0;
  vector<long long> amari;
  for (long long i = 0; i < (5); i++) {
    string temp = to_string(a[i]);
    long long c = temp[temp.size() - 1] - '0';
    if (c != 0) {
      amari.push_back(10 - c);
    }
  }
  sort(amari.begin(), amari.end());
  for (long long i = 0; i < (5); i++) {
    sum = sum + a[i];
  }
  for (long long i = 0; i < amari.size() - 1; i++) {
    sum = sum + amari[i];
  }
  cout << sum << endl;
  return 0;
}
