strs = gets.chomp.scan(/chiwa.*wa/) puts strs.length == 0 ? "-1" : strs[0].length