#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  vector<int> vec = {A, B, C, D, E};
  int max = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (vec.at(i) != 0 && max <= 10 - vec.at(i) % 10) {
      max = vec.at(i);
    }
  }
  int sum1 = 0;
  int sum2 = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (vec.at(i) != max) {
      int a = vec.at(i) % 10;
      a += sum2;
      vec.at(i) += sum1;
    } else if (vec.at(i) % 10 == max) {
      vec.at(i) += sum1;
    }
  }
  cout << 40 - sum2 + sum1 + max << endl;
}
