#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  vector<int> sad;
  int cnt = 0, a, fl = 0, mx = 10;
  for (int i = 0; i < 5; i++) {
    cin >> a;
    if (a % 10 == 0) {
      cnt += a;
    } else {
      sad.push_back(a);
      if (a % 10 < mx) {
        mx = a % 10;
        fl = a;
      }
    }
  }
  vector<int>::iterator it;
  for (it = sad.begin(); it != sad.end(); it++) {
    int xx = *it;
    if (xx == fl) {
      sad.erase(it);
      break;
    }
  }
  int j = 9, k = sad.size();
  bool gu = false;
  while (1) {
    for (int i = 0; i < sad.size(); i++) {
      if ((sad[i] % 10 == j)) {
        cnt += sad[i];
        sad[i] = -1;
        cnt += (10 - cnt % 10);
        k--;
        if (k == 0) {
          gu = true;
          break;
        }
      }
    }
    if (gu) {
      break;
    }
    j--;
  }
  cnt += fl;
  cout << cnt << "\n";
  return 0;
}
