Implemented count function for rules with 2 variables.