#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d[10], e, f;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> e;
  cin >> f;
  if (a % 10 != 0) {
    d[0] = (a / 10 + 1) * 10 - a;
  } else if (a % 10 == 0) {
    d[0] = 0;
  } else if (b % 10 != 0) {
    d[1] = (b / 10 + 1) * 10 - b;
  } else if (b % 10 == 0) {
    d[1] = 0;
  } else if (c % 10 != 0) {
    d[2] = (c / 10 + 1) * 10 - c;
  } else if (c % 10 == 0) {
    d[2] = 0;
  } else if (e % 10 != 0) {
    d[3] = (e / 10 + 1) * 10 - e;
  } else if (e % 10 == 0) {
    d[3] = 0;
  } else if (f % 10 != 0) {
    d[4] = (f / 10 + 1) * 10 - f;
  } else if (f % 10 == 0) {
    d[4] = 0;
  }
  sort(d, d + 5, greater<int>());
  cout << d[1] + d[2] + d[3] + d[4] + (a + b + c + e + f) << endl;
}
