#include <bits/stdc++.h>
using namespace std;
long long int a[6], r = 0;
int main() {
  for (int i = 0; i < 6; ++i) {
    cin >> a[i];
    if (a[i] % 5 != 0) {
      long long int r = a[i] % 10;
      if (r > 0 && r < 6) {
        a[i] = a[i] + (5 - r);
      } else {
        a[i] = a[i] + (10 - r);
      }
    }
  }
  long long int sum = 0;
  for (int i = 0; i < 6; ++i) {
    sum = sum + a[i];
  }
  cout << sum << endl;
  return 0;
}
