#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(5);
  for (int i = (0); i < (5); ++i) cin >> a[i];
  int ans = 0;
  for (int i = (0); i < (5); ++i) {
    while (a[i] % 5 != 0) ++a[i];
    ans += a[i];
  }
  cout << ans << '\n';
  return 0;
}
