#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int a_1, b_1, c_1, d_1, e_1;
  a_1 = a % 10;
  b_1 = b % 10;
  c_1 = c % 10;
  d_1 = d % 10;
  e_1 = c % 10;
  int minT = min(min(min(a_1, b_1), c_1), min(d_1, e_1));
  int ans = a + (10 - a_1) + b + (10 - b_1) + c + (10 - c_1) + d + (10 - d_1) +
            e + (10 - e_1) - minT;
  cout << ans << endl;
  return 0;
}
