#include <bits/stdc++.h>
int main() {
  int t[5];
  for (int i = 0; i < 5; i++) {
    scanf("%d", &t[i]);
  }
  double d[5];
  double sum = 0;
  for (int i; i < 5; i++) {
    d[i] = ceil((double)(t[i]) / 10);
    sum += d[i];
  }
  int sum2 = (int)sum;
  printf("%d\n", sum2);
  int max = 0;
  for (int j = 0; j < 5; j++) {
    int a = (10 - (t[j] % 10)) % 10;
    if (a > max) {
      max = a;
    }
  }
  int ans = (sum2 * 10) - max;
  printf("%d\n", ans);
  return 0;
}
