a=input() b=input() c="NESW" print((c.index(b)-c.index(a))%4)