#include <bits/stdc++.h>
int main() {
  int sum = 0;
  int dish[5];
  int rem[5];
  int max;
  int maxno;
  for (int i = 0; i < 5; i++) {
    std::cin >> dish[i];
    rem[i] = 10 - dish[i] % 10;
    if (rem[i] == 10) rem[i] = 0;
    if (i == 0) {
      max = rem[i];
      maxno = i;
      continue;
    }
    if (rem[i] >= max) {
      sum += dish[maxno] + rem[maxno];
      max = rem[i];
      maxno = i;
    } else {
      sum += dish[i] + rem[i];
    }
  }
  std::cout << dish[maxno];
  sum += dish[maxno];
  std::cout << sum << std::endl;
  return 0;
}
