#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int n;
	int t=min({(a-1)%10,(b-1)%10,(c-1)%10,(d-1)%10,(e-1)%10});
  if((a-1)%10==t){n=a+2*b+2*c+2*d+2*e-b%10-c%10-d%10-e%10}else
  if((b-1)%10==t){n=2*a+b+2*c+2*d+2*e-a%10-c%10-d%10-e%10}else
  if((c-1)%10==t){n=2*a+2*b+c+2*d+2*e-b%10-a%10-d%10-e%10}else
  if((d-1)%10==t){n=2*a+2*b+2*c+d+2*e-b%10-c%10-a%10-e%10}else
  if((e-1)%10==t){n=2*a+2*b+2*c+2*d+e-b%10-c%10-d%10-a%10}
  cout<<n<<endl;
}
