#include <bits/stdc++.h>
using namespace std;
int main() {
  int dish[5];
  int minmo = 4;
  int m[5];
  for (int i = 0; i < 5; i++) {
    cin >> dish[i];
    m[i] = dish[i] % 10;
    if (m[i] == 0) {
      m[i] = 10;
    }
  }
  for (int i = 0; i < 4; i++) {
    if (m[i] < m[i + 1]) {
      minmo = i;
    }
  }
  swap(dish[minmo], dish[4]);
  swap(m[minmo], m[4]);
  int t = 0;
  for (int i = 0; i < 4; i++) {
    t += dish[i] + (10 - m[i]);
  }
  t += dish[4];
  cout << t << endl;
}
