#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int ans =  A + B + C + D + E;
  int number = 9;
  int time = 0;
  if ( A % 10 <= number || A % 10 != '0' ) {
    number = A % 10;
  }
  time += A % 10;
  if ( B % 10 <= number || B % 10 != '0' ) {
    number = B % 10;
  }
  time += B % 10;
  if ( C % 10 <= number || C % 10 != '0' ) {
    number = C % 10;
  }
  time += C % 10;
  if ( D % 10 <= number || D % 10 != '0' ) {
    number = D % 10;
  }
  time += D % 10;
  if ( E % 10 <= number || E % 10 != '0' ) {
    number = E % 10;
  }
  time += E % 10;
  time -= number;
  time = 40 - time;
  ans += time;
  cout << ans << endl;
}