#include <bits/stdc++.h>
int main() {
  int A, B, C, D, E;
  int time, t, s = 0;
  scanf("%d\n%d\n%d\n%d\n%d", &A, &B, &C, &D, &E);
  int a[5] = {A, B, C, D, E};
  int h[5];
  for (t = 0; t < 5; t++) {
    while (a[t] % 10 != 0) {
      a[t] = a[t] + 1;
      h[t] = h[t] + 1;
    }
    time = time + a[t];
  }
  if (h[0] < h[1]) s = 1;
  if (h[0] < h[2]) s = 2;
  if (h[0] < h[3]) s = 3;
  if (h[0] < h[4]) s = 4;
  printf("%d", time - h[s]);
  return 0;
}
