#include <bits/stdc++.h>
int main(void) {
  int a, b, c, d, e;
  scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
  int m = 10;
  if (a % 10 < m && a % 10 != 0) m = a % 10;
  if (b % 10 < m && b % 10 != 0) m = b % 10;
  if (c % 10 < m && c % 10 != 0) m = c % 10;
  if (d % 10 < m && d % 10 != 0) m = d % 10;
  if (e % 10 < m && e % 10 != 0) m = e % 10;
  printf("%d\n", m);
  int t = 0;
  t += a + (1000 - a) % 10;
  t += b + (1000 - b) % 10;
  t += c + (1000 - c) % 10;
  t += d + (1000 - d) % 10;
  t += e + (1000 - e) % 10;
  t -= (10 - m);
  printf("%d\n", t);
  return 0;
}
