a=input() b=input() if a=="E" and b=="E": print("0") elif a=="E" and b=="S": print("1") elif a=="E" and b=="W": print("2") elif a=="E" and b=="N": print("3") elif a=="S" and b=="S": print("0") elif a=="S" and b=="W": print("1") elif a=="S" and b=="N": print("2") elif a=="S" and b=="E": print("3") elif a=="W" and b=="W": print("0") elif a=="W" and b=="N": print("1") elif a=="W" and b=="E": print("2") elif a=="W" and b=="S": print("3") elif a=="N" and b=="N": print("0") elif a=="N" and b=="E": print("1") elif a=="N" and b=="S": print("2") else : print("3")