#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long int> menus(5);
  vector<long long int> order = {0, 1, 2, 3, 4};
  for (long long int i = 0; i < menus.size(); ++i) scanf("%d", &menus[i]);
  long long int fans = 123 * 5 + 1;
  while (next_permutation(order.begin(), order.end())) {
    long long int ans = 0;
    for (long long int i = 0; i < menus.size(); ++i) {
      while (ans % 10 != 0) ans++;
      printf("count: %d, order: %d\n", i, order[i]);
      ans += menus[order[i]];
    }
    fans = min(fans, ans);
  }
  printf("%d\n", fans);
  return 0;
}
