x = 0 y = 0 gets.chars.each do |c| case c when "N" then y += 1 when "E" then x += 1 when "W" then x -= 1 when "S" then y -= 1 end end puts Math.sqrt(x ** 2 + y ** 2)