#include<iostream>
#include<string>
using namespace std;

int main(){
  int A[6], v, a[6], max_a, max_i = 0;
  for ( int i = 0 ; i < 5; i++){
    cin >> A[i];
    if (A[i] < 10) a[i] = to_string(A[i])[0] - '0';
    else if ( A[i] < 100 ) a[i] = to_string(A[i])[1] - '0';
    else a[i] = to_string(A[i])[2] - '0';
    if (a[i] < a[max_i] && a[i] > 0 ) max_i = i;
  }

  int sum = 0;
  for ( int i = 0; i < 5; i++){
    if ( i == max_i || a[i] == 0 ) sum += A[i];
    else {
      sum += ( A[i] + 10 - a[i] );
    }
  }

  cout << sum << endl;

  return 0;