class String def succ case self when "E" "S" when "S" "W" when "W" "N" when "N" "E" else super end end end A = gets.chomp B = gets.chomp puts (A..).find_index(B)