print(sum([[[len(str(i)),4],[4,8]][i%5==0][i%3==0]for i in map(int,input().split())]))