#include <bits/stdc++.h>
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  vector<int> data(5);
  cin >> data.at(0) >> data.at(1) >> data.at(2) >> data.at(3) >> data.at(4);
  vector<int> p = {0, 1, 2, 3, 4};
  int f_ans = 2147483647;
  do {
    int ans = 0;
    for (int i = 0; i < (5); ++i) {
      while (ans % 10 != 0) ans++;
      ans += data[i];
    }
    f_ans = min(f_ans, ans);
  } while (next_permutation(p.begin(), p.end()));
  cout << f_ans << endl;
  return 0;
}
