#include <bits/stdc++.h>
void troca(int *a, int *b) {
  int temp = *b;
  *b = *a;
  *a = temp;
}
int mod(int a, int b) {
  if ((a % 10) != 0 && (a % 10) < b % 10)
    return a;
  else
    return b;
}
int main() {
  int a, b, c, d, e, k, sum = 0;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  k = mod(mod(mod(a, b), c), d);
  if (k == a)
    troca(&a, &e);
  else if (k == b)
    troca(&b, &e);
  else if (k == c)
    troca(&c, &e);
  else if (k == d)
    troca(&d, &e);
  if ((a % 10) != 0)
    sum += a + (10 - (a % 10));
  else
    sum += a;
  if ((b % 10) != 0)
    sum += b + (10 - (b % 10));
  else
    sum += b;
  if ((c % 10) != 0)
    sum += c + (10 - (c % 10));
  else
    sum += c;
  if ((d % 10) != 0)
    sum += d + (10 - (d % 10));
  else
    sum += d;
  printf("%d\n", sum + e);
  return 0;
}
