#include <bits/stdc++.h>
const int INF = 1000000007;
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  vector<int> a(5);
  for (int i = 0; i < (5); ++i) cin >> a[i];
  vector<int> all = {0, 1, 2, 3, 4, 5};
  int solve = INF;
  do {
    int ans = 0;
    for (int j = 0; j < (5); ++j) {
      while (ans % 10 != 0) ans++;
      ans += a[all[j]];
    }
    solve = min(solve, ans);
  } while (next_permutation(all.begin(), all.end()));
  cout << solve << endl;
  return 0;
}
