#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int Max = 0;
void load(int a) {
  if (a % 10 != 0) v.push_back(10 - (a % 10));
  Max = max(Max, 10 - (a % 10));
}
int main() {
  int a, b, c, d, e;
  scanf("%d", &a);
  load(a);
  scanf("%d", &b);
  load(b);
  scanf("%d", &c);
  load(c);
  scanf("%d", &d);
  load(d);
  scanf("%d", &e);
  load(e);
  int res = 0;
  for (auto i : v) res += i;
  cout << a + b + c + d + e + res - Max;
  return 0;
}
