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