#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int atoe[5];
  int atoe_[5];
  for (int i = 0; i < 5; ++i) {
    cin >> atoe[i];
    atoe_[i] = atoe[i] % 10;
  }
  int min_place;
  int minimum = 124;
  for (int i = 0; i < 5; ++i) {
    if (atoe_[i] == 0) continue;
    if (atoe_[i] < minimum) {
      minimum = atoe_[i];
      min_place = i;
    }
  }
  int ans = 0;
  for (int i = 0; i < 5; ++i) {
    if (i == min_place) continue;
    ans += (atoe[i] + 10 - atoe_[i]);
    if (atoe_[i] == 0) ans -= 10;
  }
  ans += atoe[min_place];
  cout << ans;
}
