#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> vec(5);
  int mintime, i, j, time;
  for (i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  mintime = 643;
  for (i = 0; i < 5; i++) {
    time = 0;
    for (j = 0; j < 5; j++) {
      time += vec.at(j) + 10 - vec.at(i) % 10;
    }
    time -= 10 - vec.at(i) % 10;
    if (time < mintime) {
      mintime = time;
    }
  }
  cout << mintime << "\n";
  return 0;
}
