#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, X[5], sum = 0;
  cin >> a >> b >> c >> d >> e;
  X[0] = min(a % 10, 10 - a % 10);
  X[1] = min(b % 10, 10 - b % 10);
  X[2] = min(c % 10, 10 - c % 10);
  X[3] = min(d % 10, 10 - d % 10);
  X[4] = min(e % 10, 10 - e % 10);
  int i, j, temp;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (X[j + 1] < X[j]) {
        temp = X[j];
        X[j] = X[j + 1];
        X[j + 1] = temp;
      }
    }
  }
  for (i = 0; i < 4; i++) {
    sum += X[i];
  }
  cout << a + b + c + d + e + sum << endl;
}
