#include <bits/stdc++.h>
int main() {
  int max = 0;
  int min = INT_MAX;
  int array[5];
  int count = 0;
  int idxmax, idxmin;
  char str[124] = {'\0'};
  for (int i = 0; i < 5; i++) {
    scanf("%d", &array[i]);
    sprintf(str, "%d", array[i]);
    int a = str[strlen(str) - 1] - '0';
    if (max <= a) {
      max = a;
      idxmax = i;
    }
    if (min >= a && a != 0) {
      min = a;
      idxmin = i;
    }
  }
  int j = 0;
  int res = 0;
  int sum = array[idxmax];
  while (j < 4) {
    j++;
    res = array[j];
    if (sum % 10 == 0 && j != idxmin && j != idxmax)
      sum += res;
    else if (sum % 10 != 0 && j != idxmin && j != idxmax) {
      while (sum % 10 != 0) sum++;
      sum += res;
    }
  }
  while (sum % 10 != 0) sum++;
  sum += array[idxmin];
  printf("%d", sum);
  return 0;
}
