#include <bits/stdc++.h>
int main() {
  int a[5], b, c, d, e, f;
  scanf("%d", &a[0]);
  scanf("%d", &a[1]);
  scanf("%d", &a[2]);
  scanf("%d", &a[3]);
  scanf("%d", &a[4]);
  b = (a[0] + 10) - a[0];
  c = (a[1] + 10) - a[1];
  d = (a[2] + 10) - a[2];
  e = (a[3] + 10) - a[3];
  f = (a[4] + 10) - a[4];
  if (b > c && b > d && b > e && b > f) {
    printf("%d", (a[1] + a[2] + a[3] + a[4] + c + d + e + f + a[0]));
  } else if (c > b && c > d && c > e && c > f) {
    printf("%d", (a[0] + a[2] + a[3] + a[4] + b + d + e + f + a[1]));
  } else if (d > b && d > c && d > e && d > f) {
    printf("%d", (a[0] + a[1] + a[3] + a[4] + b + c + e + f + a[2]));
  } else if (e > b && e > c && e > d && e > f) {
    printf("%d", (a[0] + a[1] + a[2] + a[4] + b + d + c + f + a[3]));
  } else {
    printf("%d", (a[0] + a[1] + a[2] + a[3] + b + d + e + c + a[4]));
  }
  return 0;
}
