#include <bits/stdc++.h>
int cmp(const void *a, const void *b) {
  if (*(int *)a > *(int *)b) {
    return -1;
  } else if (*(int *)a < *(int *)b) {
    return 1;
  } else {
    return 0;
  }
}
int min(int a, int b) {
  if (a >= b) {
    return b;
  }
  return a;
}
int main(void) {
  int a[5];
  int sum;
  int min = 999999;
  scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
  for (int i = 0; i < 5; i++) {
    sum = 0;
    for (int j = 0; j < 5; j++) {
      for (int k = 0; k < 5; k++) {
        for (int m = 0; m < 5; m++) {
          for (int n = 0; n < 5; n++) {
            int aa = 10 - a[i] % 10;
            int bb = 10 - a[j] % 10;
            int cc = 10 - a[k] % 10;
            int dd = 10 - a[m] % 10;
            int ee = 10 - a[n] % 10;
            if (i == j || i == k || i == m || i == n || j == k || j == m ||
                j == n || k == m || k == n || m == n) {
              continue;
            }
            sum = a[i] + (aa) + a[j] + (bb) + a[k] + (cc) + a[m] + (dd) + a[n] +
                  (ee);
          }
        }
      }
    }
  }
  printf("%d\n", min);
}
