#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int x[5] = {a, b, c, d, e};
  int y[5] = {10 - (a % 10), 10 - (b % 10), 10 - (c % 10), 10 - (d % 10),
              10 - (e % 10)};
  int amari = 10;
  int lasti = 0;
  int last = 0;
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (x[i] % 10 <= amari && x[i] % 10 != 0) {
      amari = x[i] % 10;
      lasti = i;
      last = x[i];
    }
  }
  for (int i = 0; i < 5; i++) {
    if (i != lasti) {
      if (y[i] != 10) {
        ans += x[i] + y[i];
      } else {
        ans += x[i];
      }
    }
  }
  ans += last;
  cout << ans << endl;
  return 0;
}
