#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5];
  vector<int> min;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
    min.push_back(a[i] % 10);
  }
  sort(min.begin(), min.end(), greater<int>());
  int counter = 0;
  for (int i = 0; i < 5; i++) {
    if (i != 4) {
      if (a[0] % 10 == min[i]) {
        counter += a[0];
        int Temp1;
        Temp1 = 10 - (a[0] % 10);
        counter += Temp1;
      } else if (a[1] % 10 == min[i]) {
        counter += a[1];
        int Temp1;
        Temp1 = 10 - (a[1] % 10);
        counter += Temp1;
      } else if (a[2] % 10 == min[i]) {
        counter += a[2];
        int Temp1;
        Temp1 = 10 - (a[2] % 10);
        counter += Temp1;
      } else if (a[3] % 10 == min[i]) {
        counter += a[3];
        int Temp1;
        Temp1 = 10 - (a[3] % 10);
        counter += Temp1;
      } else if (a[4] % 10 == min[i]) {
        counter += a[4];
        int Temp1;
        Temp1 = 10 - (a[4] % 10);
        counter += Temp1;
      }
    } else {
      if (a[0] % 10 == min[i]) {
        counter += a[0];
      } else if (a[1] % 10 == min[i]) {
        counter += a[1];
      } else if (a[2] % 10 == min[i]) {
        counter += a[2];
      } else if (a[3] % 10 == min[i]) {
        counter += a[3];
      } else if (a[4] % 10 == min[i]) {
        counter += a[4];
      }
    }
  }
  cout << counter;
}
