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