#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1LL << 20;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  vector<int> Time = {A, B, C, D, E};
  vector<int> index = {0, 1, 2, 3, 4};
  vector<int> nextTime(5);
  for (int i = 0; i < 5; i++) {
    if (Time[i] % 10 == 0) nextTime[i] = Time[i];
    nextTime[i] = (Time[i] + 10 - 1) / 10 * 10;
  }
  int ans = (int)1e9;
  do {
    int res = 0;
    for (int i = 0; i < 5; i++) {
      while (ans % 10 != 0) ans++;
      ans += Time[index[i]];
    }
    ans = min(ans, res);
  } while (next_permutation(index.begin(), index.end()));
  cout << ans << endl;
  return 0;
}
