A = input() B = input() def f(x): if x == "E": return "W" if x == "W": return "S" if x == "S": return "N" if x == "N": return "E" count = 0 while A != B: A = f(A) count += 1 print(count)