while 1: turn=int(input()) if turn==0: break t,n,w=1,2,3 for i in range(turn): command=input() if command=='north': t,n,w=7-n,t,w elif command=='west': t,n,w=7-w,n,t elif command=='east': t,n,w=w,n,7-t else: t,n,w=n,7-t,w print(t)