title: Count number of facts in working memory
body: <p>I need to count the number of facts satisfying a certain constraint in working memory and then fire the rule if the number of facts breaches a certain threshold. I tried the following but it is complaining about "mismatched input '$cnt' in rule "Rule1"</p>
  
  <pre><code>rule Rule1
  when
      accumulate ( AFact ( code == "XXXX" ); $cnt : count(1) ; $cnt &gt; 1 )
  then
      // fire
  end
  </code></pre>
  
  <p>Any help to get the syntax right would be appreciated. Thanks!</p>