#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int T = 0;
  vector<int> A(5), B(5);
  for(int i = 0; i < 5; i++) {
    cin << A.at(i);
    B.at(i) = A.at(i)%10;
    if (B.at(i) == 0) {
      B.at(i) = 10;
    }
    B.at(i) = 10 - B.at(i);
    T = max(T,B.at(i));
  }
  int S = 0;
  for(int i = 0; i < 5; i++) {
    S += A.at(i);
  }
  int ans = S - T;
  cout << ans << endl;
  return 0;
}