#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[4];
  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];
  }
  s = h[0];
  if (h[0] < h[1])
    s = h[1];
  else if (h[0] < h[2])
    s = h[2];
  else if (h[0] < h[3])
    s = h[3];
  else if (h[0] < h[4])
    s = h[4];
  printf("%d", time - s);
  return 0;
}
