If you've already got your counter, increment it by 1 every time a bullet is created, and decrement it by 1 when a bullet is killed.
The second bit of your code checks the value of the counter and creates a bullet or not, depending on the value.
For example:
If COUNTER < 3
Create bullet
You can add an OTHERWISE statement if you want something to happen if the bullet limit has been reached.