#include <bits/stdc++.h>
int compare_f(const void* a, const void* b) {
  return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}
int compare_f2(const void* a, const void* b) {
  return *((uint64_t*)a) > *((uint64_t*)b) ? -1 : 1;
}
static size_t comb(const size_t n, const size_t r) {
  size_t result = 1;
  for (size_t i = 0; i < r; i++) {
    result *= n - i;
    result /= i + 1;
  }
  return result;
}
static uint64_t combU64(const uint64_t n, const uint64_t r) {
  uint64_t result = 1;
  for (uint64_t i = 0; i < r; i++) {
    result *= n - i;
    result /= i + 1;
  }
  return result;
}
static uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}
int main(void) {
  size_t A[5];
  scanf("%zu\n%zu\n%zu\n%zu\n%zu", &A[0], &A[1], &A[2], &A[3], &A[4]);
  size_t minIdx = 0;
  for (size_t i = 1; i < 5; i++) {
    if ((A[i] + 9) % 10 < (A[minIdx] + 9) % 10) {
      minIdx = i;
    }
  }
  size_t sum = 0;
  for (size_t i = 0; i < 5; i++) {
    sum += (i == minIdx) ? A[i] : (A[i] + 9) / 10 * 10;
  }
  printf("%zu\n", minIdx, sum);
  return 0;
}
