#「東」「西」「南」「北」 #これらは E, W, S, N のうちいずれか 文字であり、それぞれ「東」「西」「南」「北」に対応します。 a = ["E","W","S","N"] str_1 = input() str_2 = input() if str_1 == str_2: print(0) else: soe1 = a.index(str_1) soe2 = a.index(str_2) if soe1 < soe2: print(soe2-soe1) else: print(soe1-soe2)