#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
int main() {
  vector<int> v(5);
  for (int i = 0; i < (5); ++i) cin >> v[i];
  int last_order = 0;
  int r, tmp, last_order_num;
  for (int i = 0; i < (5); ++i) {
    if (v[i] % 10 != 0)
      r = v[i] % 10;
    else
      continue;
    tmp = 10 - r;
    if (tmp > last_order) {
      last_order = tmp;
      last_order_num = i;
    } else
      continue;
  }
  cout << last_order_num << endl;
  int ans = 0;
  for (int i = 0; i < (5); ++i) {
    if (i == last_order_num) continue;
    if (v[i] % 10 != 0)
      ans += ((v[i] + (10 - 1)) / 10) * 10;
    else
      ans += v[i];
  }
  ans += v[last_order_num];
  cout << ans << endl;
  return 0;
}
