#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = (long long int)1e15;
long long int A[5];
long long int dfs(vector<int> v) {
  if (v.size() == 5) {
    long long int t = 0;
    for (long long int(i) = (0); (i) < (4); ++(i)) {
      t += v[i];
      t += (10 - t % 10) % 10;
    }
    t += v[4];
    return t;
  }
  long long int min = INF;
  for (long long int(i) = (0); (i) < (5); ++(i)) {
    bool e = false;
    for (long long int(j) = (0); (j) < (v.size()); ++(j)) {
      if (A[i] == v[j]) e = true;
    }
    if (e) continue;
    v.push_back(A[i]);
    min = std::min(min, dfs(v));
    v.pop_back();
  }
  return min;
}
int main() {
  long long int t = 0;
  for (long long int(i) = (0); (i) < (5); ++(i)) {
    cin >> A[i];
  }
  vector<int> v;
  cout << dfs(v) << endl;
  return 0;
}
