#include <bits/stdc++.h>
using namespace std;
int roundUp(int n) {
  if (n % 10 == 0)
    return n;
  else
    return (10 - n % 10) + n;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<int> arr(5);
  for (int i = 0; i < 5; i++) cin >> arr[i];
  int res = 10e5;
  do {
    int t = 0;
    for (int i = 0; i < 5; i++) {
      if (t == 0)
        t += arr[i];
      else {
        t = t + roundUp(arr[i]);
      }
    }
    res = min(res, t);
  } while (next_permutation(arr.begin(), arr.end()));
  cout << res << endl;
  return 0;
}
