#include <bits/stdc++.h>
using namespace std;
long long maxtime(long long n) {
  while (n % 10 != 0) n++;
  return n;
}
long long remtime(long long n) { return maxtime(n) - n; }
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  long long sum =
      maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
  long long rem =
      min({remtime(a), remtime(b), remtime(c), remtime(d), remtime(e)});
  cout << sum - rem << endl;
  return 0;
}
