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