HateR_Kint is right. The secret is to use a count command. When you are counting alive/dead units, its usually better to combine it with an alive command. If you just use count there is sometimes a delay before the trigger activates. So, again, syntax not guaranteed but your condition line might look something like this
this and rescuesafe and prisonersafe and ("alive _x" count [loon1, loon2, loon3, loon4] < 4)