#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, E, a, b, c, d, e, sum = 0, div = 10;
  vector<int> num(5);
  vector<int> sumnum(5);
  cin >> A >> B >> C >> D >> E;
  a = A % 10;
  b = B % 10;
  c = C % 10;
  d = D % 10;
  e = E % 10;
  num = {a, b, c, d, e};
  sumnum = {A, B, C, D, E};
  for (int i = 0; i < 5; i++) {
    if (num[i] == 0) {
      sum = sum + sumnum[i];
    } else {
      if (num[i] < div) {
        div = num[i];
        sum = sum + sumnum[i] - num[i];
      } else {
        sum = sum + sumnum[i] + 10 - num[i];
      }
    }
  }
  sum = sum + div;
  cout << sum << endl;
}
