#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n == 2 || n == 3 || n == 5)
    return true;
  else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
    return false;
  else {
    for (int i = 5; i <= sqrt(n); i += 2) {
      if (n % i == 0) return false;
    }
    return true;
  }
}
int frq[50];
int main() {
  {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  };
  long long arr[5], sum = 0, r = 0, avg, k = 10000, d, x = 9;
  cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4];
  sum = arr[0] + arr[1] + arr[2] + arr[3] + arr[4];
  avg = sum / 5;
  for (int i = 0; i < 5; i++) {
    if (arr[i] % 10 != 0) r += (10 - (arr[i] % 10));
    d = abs(avg - arr[i]);
    if (d < k) {
      k = d;
      x = arr[i] % 10;
    }
  }
  if (x != 0) {
    r -= (10 - x);
  }
  sum += r;
  cout << sum;
  cout << "\n";
  return 0;
}
