How do I activate a counter?
put a counter on the clock line connect the reset to A=B on the fourth 74LS86 and connect the "too-many" output inverted to IA=B on the first 74LS86

I'm guessing twelve button presses counts as three tries, even though 12 presses presses has tested 13 different codes (including 0000) that is unless you're using excess three coding (or some other symbology that excludes the reset state)

if you're using excess three you can or-together lines 1,2,3,4 to detect when 4 digits have been entered and possibly use that in combination with the lock  output to perform a reset of the shift registers if the code is wrong - thus allowing only a single guess per 4 digits.