#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[5];
  for (int i = 0; i < 5; i++) {
    cin >> A[i];
  }
  int min_t = 10000000;
  do {
    int t = 0;
    for (int i = 0; i < 4; i++) {
      int m = A[i] % 10;
      t += A[i] + (10 - m);
    }
    t += A[4];
    min_t = min(min_t, t);
  } while (next_permutation(A, A + 5));
  cout << min_t << endl;
  return 1;
}
