#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> spot(5, 0);
  for (int i = 0; i < 5; i++) {
    cin >> spot[i];
  }
  int check = 0;
  int maxS = 0;
  vector<int> left(5, 0);
  int total = 0;
  for (int i = 0; i < 5; i++) {
    left.at(i) = spot.at(i) % 10;
    if (left.at(i) == 0) {
      left.at(i) = 0;
    } else {
      left.at(i) = 10 - left.at(i);
    }
  }
  maxS = max({left.at(0), left.at(1), left.at(2), left.at(3), left.at(4)});
  for (int i = 0; i < 5; i++) {
    if (maxS == left.at(i)) {
      check = i;
    }
  }
  for (int i = 0; i < 5; i++) {
    if (check == i) {
      total = total + spot.at(i);
    } else {
      total = total + spot.at(i) + left.at(i);
    }
  }
  cout << total << endl;
}
