#include <bits/stdc++.h>
int main(void) {
  int a, b, c, d, e;
  scanf("%d\n%d\n%d\n%d\n%d", &a, &b, &c, &d, &e);
  int aa, bb, cc, dd, ee, x, num = 0, time = 0;
  aa = a % 10;
  bb = b % 10;
  cc = c % 10;
  dd = d % 10;
  ee = e % 10;
  if (aa == 0) {
    num += 1;
  }
  if (bb == 0) {
    num += 1;
  }
  if (cc == 0) {
    num += 1;
  }
  if (dd == 0) {
    num += 1;
  }
  if (ee == 0) {
    num += 1;
  }
  x = aa >= bb && bb != 0 ? bb : aa;
  x = x >= cc && cc != 0 ? cc : x;
  x = x >= dd && dd != 0 ? dd : x;
  x = x >= ee && ee != 0 ? ee : x;
  time = a - aa + b - bb + c - cc + d - dd + e - ee + 10 * (4 - num) + x;
  printf("%d", time);
}
