#include <bits/stdc++.h>
using namespace std;
const long long mei = (long long)1e9 + 7;
int main() {
  long long a, b, c, d, e, h;
  cin >> a >> b >> c;
  cin >> d >> e;
  cout << min({(a + 9) / 10 * 10 + (b + 9) / 10 * 10 + (c + 9) / 10 * 10 +
                   (d + 9) / 10 * 10 + e,
               (a + 9) / 10 * 10 + (b + 9) / 10 * 10 + (c + 9) / 10 * 10 +
                   (e + 9) / 10 * 10 + d,
               (a + 9) / 10 * 10 + (b + 9) / 10 * 10 + (e + 9) / 10 * 10 +
                   (d + 9) / 10 * 10 + c,
               (a + 9) / 10 * 10 + (e + 9) / 10 * 10 + (c + 9) / 10 * 10 +
                   (d + 9) / 10 * 10 + b,
               (+9) / 10 * 10 + (b + 9) / 10 * 10 + (c + 9) / 10 * 10 +
                   (d + 9) / 10 * 10 + a});
  cout << endl;
}
