#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a[5];
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  int min = (a[0] - 1) % 10;
  int p = 0;
  for (int i = 1; i < 5; i++) {
    if (min > (a[i] - 1) % 10) {
      min = (a[i] - 1) % 10;
      p = i;
    }
  }
  cout << min << endl;
  int sum = 0;
  for (int i = 0; i < 5; i++) {
    sum += (p == i) ? 0 : a[i];
    sum += (sum % 10 == 0) ? 0 : 10 - sum % 10;
  }
  cout << sum + a[p] << endl;
  return 0;
}
