#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool rd(T &num) {
  char in;
  bool IsN = false;
  while (in = getchar(), in != '-' && (in < '0' || in > '9'))
    if (in == EOF) return false;
  in == '-' ? (IsN = true, num = 0) : num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') num = num * 10 + in - '0';
  return IsN ? num = -num : num, true;
}
template <class T, class S>
inline bool rd(T &num1, S &num2) {
  return rd(num1) && rd(num2);
}
template <class T, class S, class Z>
inline bool rd(T &num1, S &num2, Z &num3) {
  return rd(num1) && rd(num2) && rd(num3);
}
template <class T>
inline void _wr(T num) {
  if (num > 9) _wr(num / 10);
  putchar('0' + num % 10);
}
template <class T>
inline void wr(T num) {
  if (num < 0) putchar('-'), num = -num;
  _wr(num);
}
void debug_out() { cerr << endl; }
string to_string(string s) { return '\"' + s + '\"'; }
string to_string(char *s) { return to_string((string)s); }
string to_string(bool s) { return s ? "true" : "false"; }
template <class T>
string to_string(T array);
template <class T, class S>
string to_string(pair<T, S> s) {
  return '(' + to_string(s.first) + ',' + to_string(s.second) + ')';
}
template <class T>
string to_string(T array) {
  bool first = true;
  string res = "[";
  for (const auto &e : array) {
    if (!first) res += ",";
    first = false;
    res += to_string(e);
  }
  return res += ']';
}
template <class Head, class... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
string nico = "NicoNicoNi";
const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const long long linf = (1ll * inf) << 32 | inf;
const int mod = 1e9 + 7;
const int none = -1;
const double eps = 1e-7;
vector<int> num;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  for (register int(i) = (0); (i) < (5); ++(i)) {
    int k;
    cin >> k;
    num.push_back(k);
  }
  sort(num.begin(), num.end(), [](int a, int b) {
    int ax = a % 10, bx = b % 10;
    if (ax == 0) ax = 10;
    if (bx == 0) bx = 10;
    return ax < bx;
  });
  int ans = 0;
  for (register int(i) = (4); (i) >= (1); --(i)) {
    if (ans % 10) ans += 10 - ans % 10;
    ans += num[i];
  }
  ans += 10 - ans % 10;
  ans += num[0];
  cout << ans << '\n';
  return 0;
}
