first=input() second=input() direction={"E":0, "S":1, "W":2, "N":3} print((direction[first]-direction[second]) %4)