#include <bits/stdc++.h>
int main() {
  int menu[5];
  int time = 0;
  int i, j;
  int gosa;
  int gg = 11;
  int gn = 0;
  int check[5];
  for (i = 0; i < 0; i++) {
    check[i] = 0;
  }
  scanf("%d%d%d%d%d", &menu[0], &menu[1], &menu[2], &menu[3], &menu[4]);
  for (i = 0; i < 5; i++) {
    gg = 11;
    for (j = 0; j < 5; j++) {
      if (check[j] == 1) continue;
      gosa = 10 - menu[j] % 10;
      if (gosa == 10) gosa = 0;
      if (gg > gosa) {
        gg = gosa;
        gn = j;
      }
    }
    printf("%d\n", gn);
    time += menu[gn] + gg;
    check[gn] = 1;
  }
  time -= gg;
  printf("%d", time);
}
