#include <bits/stdc++.h>
int main() {
  int A;
  int B;
  int C;
  int D;
  int E;
  std::cin >> A >> B >> C >> D >> E;
  int a = 10 - A % 10;
  int b = 10 - B % 10;
  int c = 10 - C % 10;
  int d = 10 - D % 10;
  int e = 10 - E % 10;
  int zeroCount = 0;
  if (a == 10) {
    a = 1;
    zeroCount++;
  }
  if (b == 10) {
    b = 1;
    zeroCount++;
  }
  if (c == 10) {
    c = 1;
    zeroCount++;
  }
  if (d == 10) {
    d = 1;
    zeroCount++;
  }
  if (e == 10) {
    e = 1;
    zeroCount++;
  }
  std::multiset<std::pair<int, int>> mst{
      {a, A}, {b, B}, {c, C}, {d, D}, {e, E}};
  int count = 0;
  int tmp = 0;
  for (auto p : mst) {
    count++;
    if (count == 5) {
      tmp += p.second;
      break;
    }
    tmp += p.first + p.second;
  }
  std::cout << tmp - zeroCount << std::endl;
  return 0;
}
