#include <bits/stdc++.h>
int main() {
  int m[5];
  int a[5];
  int total = 0;
  int t = 0;
  int last = 0;
  int tmp;
  for (int i = 0; i < 5; i++) {
    m[i] = 0;
    scanf("%d", &m[i]);
  }
  for (int j = 0; j < 5; j++) {
    a[j] = m[j] % 10;
  }
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (a[j] > a[i]) {
        last = j;
      }
    }
  }
  for (int i = 0; i < 5; i++) {
    if (i != last) {
      total += m[i] + (10 - a[i]);
    } else {
      total += m[i];
    }
  }
  return 0;
}
