#include <bits/stdc++.h>
using namespace std;
int main() {
  int time[5];
  cin >> time[0] >> time[1] >> time[2] >> time[3] >> time[4];
  int saisoku = 123 * 5;
  int keika = 0;
  int machimax = 0;
  for (long long int i = 0; i < 5; i++) {
    if (machimax <= (10 - time[i] % 10) % 10)
      machimax = (10 - time[i] % 10) % 10;
    cout << (10 - time[i] % 10) % 10 << endl;
  }
  keika += time[0];
  keika += (10 - time[0] % 10) % 10;
  keika += time[1];
  keika += (10 - time[1] % 10) % 10;
  keika += time[2];
  keika += (10 - time[2] % 10) % 10;
  keika += time[3];
  keika += (10 - time[3] % 10) % 10;
  keika += time[4];
  keika += (10 - time[4] % 10) % 10;
  keika -= machimax;
  cout << keika << endl;
  return 0;
}
