#include <bits/stdc++.h>
using namespace std;
int main() {
  int num[5], order[5] = {0, 1, 2, 3, 4};
  for (int i = 0; i < 5; i++) {
    cin >> num[i];
  }
  int ans = INT_MAX, time = 0;
  do {
    time = num[order[0]];
    for (int i = 1; i < 5; i++) {
      while (time % 10 != 0) {
        time++;
      }
      time += num[order[i]];
    }
    ans = min(ans, time);
  } while (next_permutation(order, order + 5));
  cout << ans << endl;
  return 0;
}
