#include <bits/stdc++.h>
using namespace std;
long long a[6], k, b[6];
int main() {
  long long n = 5;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) {
    if (a[i] % 10 == 0)
      b[i] == 0;
    else
      b[i] = (a[i] / 10 + 1) * 10;
  }
  for (long long i = 1; i < n - 1; i++) {
    for (long long j = i + 1; j < n; j++) {
      if (b[i] > b[j]) swap(b[i], b[j]);
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (b[i] == 0 && a[i] % 10 == 0 && i == 1)
        swap(a[i], a[1]);
      else {
        if (b[i] == 0 && a[i] % 10 == 0) {
          for (long long x = 1; x <= n; x++) {
            if (a[x] % 10 != 0) a[x] = a[n], a[i] = a[x];
          }
        } else {
          for (long long x = 1; x <= n; x++) {
            for (long long y = 1; y <= n; y++) {
              if (a[x] % 10 == b[y]) a[x] = a[y], a[y] = a[n];
            }
          }
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (k == 0)
      k = a[i];
    else {
      if (k % 10 == 0) {
        k += a[i];
      } else {
        k = (k / 10 + 1) * 10 + a[i];
      }
    }
  }
  cout << k << endl;
  return 0;
}
