#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  vector<int> vec(5);
  for (auto &el : vec) cin >> el;
  int res = 9999999;
  for (int j = 0; j < 5; ++j) {
    vector<int> arr(5);
    rotate_copy(vec.begin(), vec.begin() + j, vec.end(), arr.begin());
    for (auto el : arr) cout << el << ' ';
    cout << endl;
    int t = 0, i = 0;
    while (i < 5) {
      while (t % 10 != 0) t++;
      t += arr[i++];
    }
    res = min(res, t);
  }
  cout << res << endl;
  return 0;
}
