#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5], b[5], k, t = 643, s, h = 0;
  for (k = 0; k < 4; k++) {
    cin >> a[k];
  }
  for (k = 0; k < 4; k++) {
    if (a[k] % 10 == 0) {
      b[k] = a[k];
      continue;
    }
    b[k] = a[k] + (10 - (a[k] % 10));
  }
  for (k = 0; k < 4; k++) {
    h += b[k];
  }
  for (k = 0; k < 4; k++) {
    s = h - b[k] + a[k];
    if (s < t) {
      t = s;
    }
  }
  cout << t << endl;
  return 0;
}
