d = { "N" : 0, "E" : 1, "S" : 2, "W" : 3 } s = d[input()] t = d[input()] print((t-s)%4)