Try this script:
_i = count magazines player
_j = 0
_n = 0
#Loop
?_j==_i : goto "check"
?(magazines player select _j) == "M21": _n=_n+1
_j=_j+1
~.01
goto "Loop"
#Check
?_n <= 2: goto "hint"
_j=0
_n=0
_i = count magazines player
~.01
goto "Loop"
#Hint
hint format ["You have %1 magazines left", _n]
exit
-Pilot