Another (faster) solution is /filtering the source file to a dummy window and checking $filtered to tell how many lines matched.
Code:

on *:TEXT:.qammount *:#:{
  window -h @@
  filter -fw file.txt @@ * $+ $2-*
  window -c @@
  msg # There were $filtered lines matching to ' $+ $2-'
}