S=input().split(' ') #print(len(S[0])) sum=0 for i in range(5): if( int(S[i]) % 3 == 0 and int(S[i]) % 5 ==0): sum=sum+8 elif( int(S[i]) % 3 == 0): sum=sum+4 elif( int(S[i]) % 5 == 0): sum=sum+4 else: sum=sum+len(S[i]) print(sum)