#include <bits/stdc++.h>
using namespace std;
int main() {
  double A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int A_one = (int)A % 10 % 10;
  if (A_one == 0) A_one += 9;
  int B_one = (int)B % 10 % 10;
  if (B_one == 0) B_one += 9;
  int C_one = (int)C % 10 % 10;
  if (C_one == 0) C_one += 9;
  int D_one = (int)D % 10 % 10;
  if (D_one == 0) D_one += 9;
  int E_one = (int)E % 10 % 10;
  if (E_one == 0) E_one += 9;
  int minnum = min({A_one, B_one, C_one, D_one, E_one});
  cout << minnum << endl;
  if (minnum == A_one)
    cout << A + (ceil(B / 10) * 10) + (ceil(C / 10) * 10) +
                (ceil(D / 10) * 10) + (ceil(E / 10) * 10)
         << endl;
  else if (minnum == B_one)
    cout << B + (ceil(A / 10) * 10) + (ceil(C / 10) * 10) +
                (ceil(D / 10) * 10) + (ceil(E / 10) * 10)
         << endl;
  else if (minnum == C_one)
    cout << C + (ceil(B / 10) * 10) + (ceil(A / 10) * 10) +
                (ceil(D / 10) * 10) + (ceil(E / 10) * 10)
         << endl;
  else if (minnum == D_one)
    cout << D + (ceil(B / 10) * 10) + (ceil(C / 10) * 10) +
                (ceil(A / 10) * 10) + (ceil(E / 10) * 10)
         << endl;
  else if (minnum == E_one)
    cout << E + (ceil(B / 10) * 10) + (ceil(C / 10) * 10) +
                (ceil(D / 10) * 10) + (ceil(A / 10) * 10)
         << endl;
}
