A = gets.chomp B = gets.chomp hougaku = Enumerator.produce(A) { |prev| case prev when "E" "S" when "S" "W" when "W" "N" when "N" "E" end } puts hougaku.find_index(B)