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