#include <bits/stdc++.h>
using namespace std;
vector<int> v(5);
int solve() {
  sort(v.begin(), v.end());
  int ans = 1 << 30;
  do {
    int sum{};
    int t;
    for (auto vv : v) {
      sum += vv;
      if (sum % 10 != 0) {
        t = 10 - (sum % 10);
        sum += t;
      }
    }
    sum -= t;
    ans = min(ans, sum);
  } while (next_permutation(v.begin(), v.end()));
  return ans;
}
int main() {
  for (int i = (0); i < (5); ++i) cin >> v[i];
  cout << solve() << endl;
}
