A = input() B = input() K = {'E': 0, 'S': 1, 'W': 2, 'N': 3} if K[B] - K[A] < 0: a = K[B] - K[A] + 4 else: a = K[B] - K[A] print(a)