#include <bits/stdc++.h>
int main() {
  int a, b, c, d, e;
  int ex[5];
  scanf("%d", &a);
  ex[0] = 10 - a % 10;
  scanf("%d", &b);
  ex[1] = 10 - b % 10;
  scanf("%d", &c);
  ex[2] = 10 - c % 10;
  scanf("%d", &d);
  ex[3] = 10 - d % 10;
  scanf("%d", &e);
  ex[4] = 10 - e % 10;
  int max = 0;
  for (int i = 0; i < 5; i++) {
    if (max < ex[i]) max = ex[i];
  }
  int ans = 0;
  ans = a + b + c + d + e + ex[0] + ex[1] + ex[2] + ex[3] + ex[4] - max;
  printf("%d\n", ans);
}
