#include <bits/stdc++.h>
int amari(int x) { return x % 10; }
int min(int *x) {
  int min = x[0];
  int i, count = 0;
  for (i = 1; i < 5; i++) {
    if (min > x[i]) min = x[i];
    count++;
  }
  return count;
}
int main(void) {
  int A, B, C, D, E, k;
  int a[5];
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  scanf("%d", &E);
  a[0] = amari(A);
  a[1] = amari(B);
  a[2] = amari(C);
  a[3] = amari(D);
  a[4] = amari(E);
  k = min(a);
  if (k = 0)
    printf("%d", A + B + C + D + E + 40 - a[1] - a[2] - a[3] - a[4]);
  else if (k = 1)
    printf("%d", A + B + C + D + E + 40 - a[0] - a[2] - a[3] - a[4]);
  else if (k = 2)
    printf("%d", A + B + C + D + E + 40 - a[0] - a[1] - a[3] - a[4]);
  else if (k = 3)
    printf("%d", A + B + C + D + E + 40 - a[0] - a[1] - a[2] - a[4]);
  else
    printf("%d", A + B + C + D + E + 40 - a[0] - a[2] - a[3] - a[1]);
  printf("\n");
  return 0;
}
