#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int digit(int num) { return log10(num) + 1; }
int main() {
  vector<int> vec(5);
  vector<int> rests(5);
  int n = 5;
  int min_rest = 9;
  int last;
  int sum = 0;
  for (int i = 0; i < (int)(n); i++) cin >> vec[i];
  ;
  for (int i = 0; i < (int)(n); i++) {
    int num = 0;
    int rest = vec[i] % 10;
    rests[i] = rest;
    if (rest < min_rest && rest != 0) {
      min_rest = rest;
      last = vec[i];
    }
  };
  for (int i = 0; i < (int)(n); i++) {
    if (vec[i] == last)
      continue;
    else if (rests[i] == 0)
      sum += vec[i];
    else {
      sum += vec[i];
      sum += 10 - rests[i];
    }
  }
  sum += last;
  cout << sum << endl;
}
