#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  vector<int> a = {10 - A % 10, 10 - B % 10, 10 - C % 10, 10 - D % 10,
                   10 - E % 10};
  int b = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < 4; i++) {
    if (a.at(i) == 10) {
      a.at(i) = 0;
    }
    b = b + a.at(i);
  }
  cout << A + B + C + D + E + b << endl;
}
