#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5];
  for (int i = 0; i < (int)(5); i++) cin >> a[i];
  int ten[5] = {0};
  int max = 0;
  int cou = 0;
  for (int i = 0; i < 5; i++) {
    while ((a[i] + cou) % 10 != 0) {
      ten[i]++;
      cou++;
    }
    if (ten[i] > max) {
      max = ten[i];
    }
    cou = 0;
  }
  int ans = 0;
  for (int i = 0; i < (int)(5); i++) {
    ans += a[i];
    if (ten[i] != max) {
      ans += ten[i];
    }
  }
  cout << ans << endl;
}
