#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> lunch(5);
  for (int i = 0; i < 5; i++) {
    cin >> lunch[i];
  }
  int sum = 1e9;
  do {
    int ans = 0;
    for (int i = 0; i < 5; i++) {
      while (ans % 10 != 0) ans++;
      ans += lunch[i];
    }
    sum = min(sum, ans);
  } while (next_permutation(lunch.begin(), lunch.end()));
  cout << sum << endl;
  return 0;
}
