while 1: n=0 for x in`input()`:n=n*8--int(x)*4/5 print n