#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
int gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
int digsum(int n) {
  int res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}
int dignum(int n) {
  int res = 0;
  while (n > 0) {
    res++;
    n /= 10;
  }
  return res;
}
int stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }
int lcm(long long x, long long y) { return x / gcd(x, y) * y; }
int combi(int n, int r) {
  int num = 1;
  for (int i = 1; i <= r; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}
int main() {
  vector<int> l, a, b;
  int n = 5;
  int count = 0;
  for (int i = 0; i < n; i++) {
    int j;
    cin >> j;
    count += j;
    l.push_back(j);
  }
  for (int i = 0; i < n; i++) {
    a.push_back(l[i] % 10);
  }
  for (int i = 0; i < n; i++) {
    b.push_back(10 - a[i]);
  }
  sort((b).begin(), (b).end());
  for (int i = 0; i < n; i++) {
    count += b[i];
  }
  count -= b[4];
  cout << count;
}
