Define Counter = 0
Foreach     in  
Foreach     in  
  If     Counter ++;
  End
End
End
Return  Counter;
Algorithm 2: .