gets;p %{S W E N}.map{|c|$_.count(s)*1i**$.+=1}.sum.abs