#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int main() {
  vector<int> a(5), b(5);
  int mini = 10, temp_i, time = 0, index = 0, count = 0;
  for (int i = 0; i < (5); ++i) {
    cin >> a[i];
    b[i] = a[i] % 10;
    if (b[i] % 10 != 0) {
      mini = min(mini, b[i]);
      if (mini == b[i]) temp_i = i;
    }
  }
  while (true) {
    if (time % 10 == 0 && count != 4) {
      if (index != temp_i) {
        time += a[index];
        index++;
        count++;
        cout << time << endl;
      } else {
        index++;
      }
    } else if (time % 10 == 0 && count == 4) {
      break;
    } else {
      time++;
      continue;
    }
  }
  time += a[temp_i];
  cout << time << endl;
}
