#include <bits/stdc++.h>
int main() {
  int a[5];
  int k;
  for (auto i = 0; i < 5; i++) {
    std::cin >> a[i];
  }
  std::cin >> k;
  int min = 9999;
  auto isOk = true;
  for (auto i = 0; i < 5; i++) {
    int b[5] = {false, false, false, false, false};
    auto tmp = 0;
    tmp += (a[i] / 10) * 10;
    for (auto j = 0; j < 5; j++) {
      if (b[j]) continue;
      b[j] = true;
      tmp += (a[j] / 10) * 10;
      for (auto k = 0; k < 5; j++) {
        if (b[k]) continue;
        b[k] = true;
        tmp += (a[k] / 10) * 10;
        for (auto l = 0; l < 5; l++) {
          if (b[l]) continue;
          b[l] = true;
          tmp += (a[l] / 10) * 10;
          for (auto m = 0; m < 5; m++) {
            if (b[m]) continue;
            b[m] = true;
            tmp += (a[l] / 10) * 10;
            if (min < tmp) {
              min = tmp;
            }
          }
        }
      }
    }
  }
  std::cout << min;
}
