S = ["E","S","W","N"] A = input() B = input() A_s = 90 * S.index(A) B_s = 90 * S.index(B) print(abs(A_s-B_s)//90)