Minecraft wiki entry for Target_selectors, associated text: Examples in Bedrock Edition:
@a[c=3] — Select the nearest three players.
@a[c=-4] — Select the furthest four players.
@r[c=2] — Select two living players, chosen randomly.