#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    vector<int>time={a,b,c,d,e};
    vector<int>index={0,1,2,3,4};
    int bestTime=(int)1e9;//10の9乗

    do{
        int Nowtime=0;
        for(int i=0;i<N;i++){
            while(Nowtime%10!=0)Nowtime++;
            Nowtime+=time[index[i]];
        }
        besttime=min(Nowtime,bestTime);
    }while(next_permutation(index.begin(),index.end()));
    
}