#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  int abcde[5];
  int junban[5];
  map<int, int> one;
  for (int i = 0; i < 5; i++) cin >> abcde[i];
  for (int i = 0; i < 5; i++) one[abcde[i] % 10] = i;
  for (int i = 0; i < 5; i++) {
    if (i % 2 == 0)
      junban[i] = one.rbegin()->first;
    else
      junban[i] = one.begin()->first;
  }
  for (int i = 0; i < 5; i++) ans += abcde[junban[i]];
  cout << ans;
  return 0;
}
