#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int dx[] = {0, 1, -1, 0, 1, -1, 1, -1};
int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};
int main() {
  vector<int> v(5);
  int maxw = 0, idx;
  for (int i = 0; i < 5; i++) {
    int a;
    cin >> a;
    v[i] = a;
    int wait = (130 - a) % 10;
    if (wait > maxw) {
      maxw = wait;
      idx = i;
    }
  }
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (i == idx) continue;
    ans += v[i] + (130 - v[i]) % 10;
  }
  ans += v[idx];
  cout << ans << endl;
}
