#include <bits/stdc++.h>
int main() {
  int A, B, C, D, E;
  int time, t = 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[4];
  for (t = 0; t < 5; t++) {
    for (;;)
      if (a[t] % 10 != 0) {
        a[t] = a[t] + 1;
        h[t] = h[t] + 1;
      } else {
        time = time + a[t];
        exit(1);
      }
  }
  if (h[0] < h[1])
    h[0] = h[1];
  else if (h[0] < h[2])
    h[0] = h[2];
  else if (h[0] < h[3])
    h[0] = h[3];
  else if (h[0] < h[4])
    h[0] = h[4];
  printf("%d", time - h[0]);
  return 0;
}
