#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5], ans = 0;
  bool b = false;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
    ans += (a[i] + 9) / 10 * 10;
  }
  cout << ans << endl;
  int tmp = ans;
  for (int i = 0; i < 5; i++) {
    if (a[i] % 10 != 0) {
      int m = a[i] % 10;
      m += tmp - 10;
      ans = min(ans, m);
    }
  }
  cout << ans << endl;
}
