There’s a secret formula: $$[grid:Global-Document-People]. It returns a table of all users in the doc, so you can .Count() on that. It includes system users like Automation Bot and System Writer though, so adjust accordingly:

WARNING: really unsafe to use in production! It may get you on the radar and your doc disabled by Codans.
Props to @Dalmo_Mendonca for discovering this.