gets(p) p 998.downto(0).map{|i|$_.scan("(#{?^*i})").size}.max