#include <bits/stdc++.h>
using namespace std;
string s, s1;
long long int ar[250007], cr[200098], a, b, test, sum, t,
    x = 0, p, q, y, i, j, k = 0, l, cnteven = 0, w = 0, cnt;
map<long long int, long long int> mp, br;
int main() {
  long long int test;
  for (i = 1; i <= 5; i++) cin >> ar[i];
  long long int p;
  for (j = 1; j <= 5; j++) {
    k = 0;
    for (i = 0; i <= 130; i = k * 10) {
      if (ar[j] <= i) {
        if (i - ar[j] > cnt) {
          cnt = i - ar[j];
          p = ar[j];
          break;
        }
      }
      k++;
    }
  }
  sum = 0;
  for (j = 1; j <= 5; j++) {
    k = 0;
    if (ar[j] != p)
      for (i = 0; i <= 130; i = k * 10) {
        if (ar[j] <= i) {
          sum += i;
          break;
        }
        k++;
      }
  }
  cout << sum + p;
}
