a=list(map(int,input().split())) sum=0 for i in range(0,5): if(a[i]%15 == 0): sum+=8 elif(a[i]%3 == 0 or a[i]%5 == 0): sum+=4 else: sum+=len(str(a[i])) print(sum)