#include <bits/stdc++.h>
using namespace std;
int main(void) {
  vector<tuple<int, int>> L;
  string t_s = " ";
  int t_back = 0, t = 0;
  int ans = 0, extra = 0;
  for (int i = 0; i < 5; i++) {
    cin >> t_s;
    t_back = t_s.back() - '0';
    t = stoi(t_s);
    if (t_back == 0) {
      ans += t;
    } else {
      ans += t + 10 - t_back;
      L.push_back(make_tuple(t_back, t));
    }
  }
  sort(L.begin(), L.end());
  extra = 10 - get<0>(L[0]);
  cout << ans - extra;
}
