l=["E","S","W","N"] a=l.index(input()) b=l.index(input()) if a<=b: print(b-a) else: print(b+4-a)