#include <bits/stdc++.h>
using namespace std;
void bubbleSort(int A[], int Amod[], int N) {}
int main() {
  int i = 0;
  int A[5];
  int Amod10[5];
  int flag = 0;
  int stay = 0;
  int time = 0;
  for (int i = 0; i < 5; ++i) {
    cin >> A[i];
    Amod10[i] = A[i] % 10;
    if (Amod10[i] == 0) {
      ++flag;
    }
  }
  bool sortflag = 1;
  for (i = 0; sortflag; ++i) {
    sortflag = false;
    for (int j = 4; j >= i + 1; --j) {
      if (Amod10[j] < Amod10[j - 1]) {
        swap(Amod10[j], Amod10[j - 1]);
        swap(A[j], A[j - 1]);
        sortflag = 1;
      }
    }
  }
  swap(Amod10[flag], Amod10[4]);
  swap(A[flag], A[4]);
  for (i = 0; i < 4; ++i) {
    stay += 10 - Amod10[i];
  }
  stay = 10 * flag - stay;
  stay = abs(stay);
  for (i = 0; i < 5; ++i) {
    time += A[i];
  }
  time += stay;
  cout << time << endl;
}
