#include <bits/stdc++.h>
using namespace std;
int check_last(int a, int b, int c, int d, int e) {
  int num1 = a % 10;
  int num2 = b % 10;
  int num3 = c % 10;
  int num4 = d % 10;
  int num5 = e % 10;
  int min = num1;
  if (num2 != 0 && min > num2) min = num2;
  if (num3 != 0 && min > num3) min = num3;
  if (num4 != 0 && min > num4) min = num4;
  if (num5 != 0 && min > num5) min = num5;
  if (a % 10 == min) {
    return a;
  } else if (b % 10 == min) {
    return b;
  } else if (c % 10 == min) {
    return c;
  } else if (d % 10 == min) {
    return d;
  } else if (e % 10 == min) {
    return e;
  }
}
int Advance_number(int num) {
  if (num % 10 == 0) {
    num = num;
  } else if (num % 10 > 0) {
    int a_num = num / 10;
    num = a_num + 1;
    num = num * 10;
  }
  return num;
}
int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int min = check_last(a, b, c, d, e);
  cout << min << endl;
  int ans = 0;
  if (min == a) {
    ans += Advance_number(b);
    ans += Advance_number(c);
    ans += Advance_number(d);
    ans += Advance_number(e);
    ans += a;
  } else if (min == b) {
    ans += Advance_number(a);
    ans += Advance_number(c);
    ans += Advance_number(d);
    ans += Advance_number(e);
    ans += b;
  } else if (min == c) {
    ans += Advance_number(a);
    ans += Advance_number(b);
    ans += Advance_number(d);
    ans += Advance_number(e);
    ans += c;
  } else if (min == d) {
    ans += Advance_number(a);
    ans += Advance_number(b);
    ans += Advance_number(c);
    ans += Advance_number(e);
    ans += d;
  } else if (min == e) {
    ans += Advance_number(a);
    ans += Advance_number(b);
    ans += Advance_number(c);
    ans += Advance_number(d);
    ans += e;
  }
  cout << ans << endl;
}
