Enemy count can be gotten from $gameMap._enemies.length
To set a variable using script call, the code is $gameVariables.setValue(id, value) where id is the variable ID and value is the value to set it to.
eg: $gameVariables.setValue(1, $gameMap._enemies.length) will set the variable 1 to the total number of enemies.
To get the total number of living enemies, you need to filter the array:
$gameMap._enemies.filter(map_enemy => !!map_enemy._battler.isAlive()).length will give the number of enemies that are alive