h=Hash.new{0} gets.chars.each{|c|h[c] += 1} w = h[?W] - h[?E] d = h[?N] - h[?S] puts Math.sqrt(w*w+d*d)