#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[5], B[5], tmp = 0, sum = 0;
  for (int i = 0; i < 5; ++i) cin >> A[i];
  for (int i = 0; i < 5; ++i) {
    B[i] = 10 - A[i] % 10;
    if (B[i] == 10) B[i] = 0;
    tmp = max(B[i], tmp);
  }
  cout << tmp << endl;
  for (int i = 0; i < 5; ++i) {
    if (B[i] == 0)
      sum += A[i];
    else
      sum += int(A[i] / 10 + 1) * 10;
  }
  cout << sum - tmp << endl;
}
