#include <bits/stdc++.h>
int main(void) {
  int a, b, c, d, e;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  int A, B, C, D, E;
  A = a % 10;
  B = b % 10;
  C = c % 10;
  D = d % 10;
  E = e % 10;
  int max = A;
  int count;
  int data[5] = {A, B, C, D, E};
  for (int i = 1; i < 5; i++) {
    if (max < data[i]) {
      max = data[i];
      count = i;
    }
  }
  int DATA[5] = {a, b, c, d, e};
  int total = 0;
  for (int i = 0; i < 5; i++) {
    if (i != count) {
      total += (DATA[i] + (10 - data[i]));
    }
  }
  total += DATA[count];
  printf("%d\n", total);
  return 0;
}
