#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(5);
  int minSum = 9999999;
  int curSum;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < 5; i++) {
    curSum = a[i];
    for (int j = 0; j < 5; j++) {
      if (i == j) continue;
      if (curSum % 10 != 0) {
        curSum += 10 - (curSum % 10);
      }
      curSum += a[j];
      for (int k = 0; k < 5; k++) {
        if (i == k || j == k) continue;
        if (curSum % 10 != 0) {
          curSum += 10 - (curSum % 10);
        }
        curSum += a[k];
        for (int l = 0; l < 5; l++) {
          if (i == l || l == j || k == l) continue;
          if (curSum % 10 != 0) {
            curSum += 10 - (curSum % 10);
          }
          curSum += a[l];
          for (int m = 0; m < 5; m++) {
            if (i == m || j == m || k == m || l == m) continue;
            if (curSum % 10 != 0) {
              curSum += 10 - (curSum % 10);
            }
            curSum += a[m];
            minSum = min(minSum, curSum);
          }
        }
      }
    }
  }
  cout << minSum << endl;
  return 0;
}
