#include<iostream>
#include<algorithm>
using namespace std;
int totaltime;
int mintime=0x7fffffff;
int time[5];
int main(){
	for(int i=0;i<5;++i)
		cin>>time[i];
	sort(time,time+5);
	do{
		totaltime=0;
		for(int i=0;i<4;++i){
			totaltime+=time[i];
			while(totaltime%10)
				++totaltime;
		}
		totaltime+=time[4];
		mintime=min(totaltime,mintime);
//		cout<<time[0]<<' '<<time[1]<<' '<<time[2]<<' '<<time[3]<<' '<<time[4]<<' '<<'	'<<totaltime<<endl;
	}while(next_permutation(time,time+5));
	cout<<mintime<<endl;
	return 0;
}