A = input() B = input() D = "NESW" a = D.find(A) b = D.find(B) print((b-a)+(4*(a>b)))