d = ["E", "S", "W", "N", "E", "S", "W", "N"] a = input() b = input() ap = d.index(a) bp = d.index(b) if bp - ap >=0: print(bp - ap) else: print(4 + bp - ap)