#include <bits/stdc++.h>
int main() {
  int A, B, C, D, E;
  int time, t, s, j = 0;
  scanf("%d\n%d\n%d\n%d\n%d", &A, &B, &C, &D, &E);
  int a[5] = {A, B, C, D, E};
  int h[5] = {0, 0, 0, 0, 0};
  for (t = 0; t < 5; t++) {
    while (a[t] % 10 != 0) {
      a[t] = a[t] + 1;
      h[t] = h[t] + 1;
    }
    time = time + a[t];
  }
  printf("%d\n", h[2]);
  for (s = 0; s < 5; s++) {
    if (h[s] > h[0]) h[0] = h[s];
  }
  printf("%d", time - h[0]);
  return 0;
}
