#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 5;
  int dishes[5];
  int t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    dishes[i] = t;
  }
  int time = 0;
  int i = 0;
  while (1) {
    if (time < dishes[i]) {
      time += 10;
      dishes[i] -= 10;
      continue;
    } else if (dishes[i] <= 10) {
      i++;
      time += 10;
    }
    if (i >= 5) break;
  }
  cout << time << endl;
}
