#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> req(5);
  for (int i = 0; i < 5; ++i) cin >> req[i];
  int max_def = 0;
  int res = 0;
  for (int i = 1; i < 124; ++i) {
    for (int k = 0; k < 5; ++k) {
      int a = i - req[k];
      if (0 <= a && a < 10) {
        if (max_def < a) {
          max_def = a;
          res = req[k];
        }
      } else {
        continue;
      }
    }
  }
  int result = 0;
  for (int k = 0; k < 5; ++k) {
    if (req[k] != res) {
      result += req[k];
    } else {
      result += req[k];
      continue;
    }
    while (true) {
      if (req[k] % 10 == 0) {
        break;
      } else {
        req[k]++;
        if (req[k] % 10 == 0) {
          break;
        } else {
          result++;
        }
      }
    }
  }
  cout << result << endl;
}
