#include <bits/stdc++.h>
using namespace std;
template <typename T>
void OutN(T x) {
  size_t i, len = x.size() - 1;
  for (i = 0; i < len; i++) cout << x[i] << " ";
  cout << x[len] << '\n';
}
template <typename T>
void Outit(T x) {
  auto end = x.end();
  end--;
  for (auto it = x.begin(); it != end; it++) cout << *it << " ";
  cout << *end << '\n';
}
template <typename T>
void Debug(const T &val) {
  cerr << val << '\n';
}
template <typename T, typename... Args>
void Debug(const T &val, Args... args) {
  cerr << val << ' ';
  Debug(std::forward<Args>(args)...);
}
template <typename T>
inline bool Max(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool Min(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
using V = vector<T>;
template <typename T>
using VV = V<V<T> >;
static const long long MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  V<pair<int, int> > v;
  pair<int, int> p;
  int x;
  int time = 0;
  int i;
  for ((i) = 0; (i) < (5); (i)++) {
    cin >> x;
    v.push_back(make_pair(min(x % 10, 10 - (x % 10)), x));
  }
  sort((v).begin(), (v).end());
  for ((i) = 0; (i) < (4); (i)++) {
    p = v[i];
    time += p.second;
    while (time % 10 != 0) time++;
  }
  cout << (time + v[4].second) << '\n';
  return 0;
}
