#include <bits/stdc++.h>
using namespace std;
int costCheck(int n) {
  int cost;
  if (n < 10) {
    cost = 10 - n;
  } else {
    if (n % 10 != 0) {
      cost = 10 - (n % 10);
    } else {
      cost = 0;
    }
  }
  return cost;
}
int maxCostCheck(int a, int b) {
  if (a < b) {
    return b;
  } else {
    return a;
  }
}
int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int costA = costCheck(a);
  int costB = costCheck(b);
  int maxCost = maxCostCheck(costA, costB);
  int costC = costCheck(c);
  maxCost = maxCostCheck(maxCost, costC);
  int costD = costCheck(d);
  maxCost = maxCostCheck(maxCost, costD);
  int costE = costCheck(e);
  maxCost = maxCostCheck(maxCost, costE);
  cout << maxCost << endl;
  int ans = a + costA + b + costB + c + costC + d + costD + e + costE - maxCost;
  cout << ans << '\n';
  return 0;
}
