a = input() b = input() direct = ["N","E","S","W","N","E","S","W"] while direct[0]!=a: del direct[0] print(direct.index(b))