#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);
  int v[5];
  int time = 0;
  int x;
  int m = INT_MAX;
  int index = 0;
  int i, j;
  for ((i) = 0; (i) < (5); (i)++) cin >> v[i];
  for ((i) = 0; (i) < (5); (i)++) {
    x = 10 - (v[i] % 10);
    if (x < m) {
      index = i;
      m = x;
    }
  }
  time += v[index];
  v[index] = 0;
  while (time % 10 != 0) time++;
  m = INT_MAX;
  for ((j) = 0; (j) < (3); (j)++) {
    for ((i) = 0; (i) < (5); (i)++) {
      if (v[i] <= 0) continue;
      x = 10 - ((time + v[i]) % 10);
      if (x < m) {
        index = i;
        m = x;
      }
    }
    time += v[index];
    v[index] = 0;
    while (time % 10 != 0) time++;
    m = INT_MAX;
  }
  for ((i) = 0; (i) < (5); (i)++) {
    if (v[i] <= 0) continue;
    Debug(i);
    time += v[i];
    break;
  }
  cout << (time) << '\n';
  return 0;
}
