r=raw_input f=lambda n:n>[]and'8 !%)&'.find(chr(hash(`n[-3:]`)%64))+f(n[:-3])*10 while 1:print f(zip(r(),r(),r()))