#include <bits/stdc++.h>
int main(void) {
  int a[6], ans = 0, kari = 9, max = 9, taihi;
  for (int i = 0; i < 5; i++) {
    if (scanf("%d", &a[i]) == 1)
      ;
  }
  for (int i = 0; i < 5; i++) {
    if (max > (a[i] % 10) && a[i] % 10 != 0) {
      max = a[i] % 10;
      kari = i;
    }
  }
  if (kari != 4) {
    taihi = a[kari];
    a[kari] = a[4];
    a[4] = taihi;
  }
  for (int i = 0; i < 5; i++) {
    while (ans % 10 != 0) {
      ans++;
    }
    ans += a[i];
  }
  printf("%d", ans);
  return 0;
}
