#include <bits/stdc++.h>
int main() {
  int A, B, C, D, E;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  scanf("%d", &E);
  int i, j, k, time[5] = {A, B, C, D, E}, order[5], flag[5], total, min = 1000;
  for (i = 0; i < 120; i++) {
    order[0] = i / 24;
    order[1] = (i % 24) / 6;
    order[2] = (i % 6) / 3;
    order[3] = (i % 3) / 2;
    order[4] = 1;
    for (j = 0; j < 5; j++) flag[j] = 0;
    total = 0;
    for (j = 0; j < 5; j++) {
      for (k = 0; k < 5; k++) {
        if (flag[k] == 1) {
          order[j]--;
          if (order[j] == 0) break;
        }
      }
      flag[k] = 0;
      total += (time[k] + 9) / 10 * 10;
    }
    if (total < min) min = total;
  }
  printf("%d\n", min);
  fflush(stdout);
  return 0;
}
