#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> time(5);
  vector<int> ex(5);
  int sum = 0;
  for (int i = 0; i < 5; i++) {
    cin >> time[i];
    ex[i] = time[i] % 10;
  }
  int min = 100;
  int cnt = 0;
  for (int i = 0; i < 5; i++) {
    if (ex[i] == 0)
      sum += time[i];
    else {
      if (ex[i] > 0 && ex[i] < min) {
        min = ex[i];
        cnt = i;
      }
    }
  }
  for (int i = 0; i < 5; i++) {
    if (ex[i] == 0)
      continue;
    else {
      if (ex[i] > 0 && ex[i] != min) sum += time[i] + (10 - ex[i]);
    }
  }
  cout << min << endl;
  sum += time[cnt];
  cout << sum;
  cout << endl;
  return 0;
}
