s=' '*50 n=0 while 1: for x in raw_input():n+=x>s>s[-1];s=s[1:]+(`n`+x*('#'>x)+s)[x