Here is a quote from Wikipedia, specifically, https://en.wikipedia.org/wiki/Roman_legion
The Roman legion was the largest military unit of the Roman army. A
legion was roughly of brigade size, composed of 4,200 infantry and 300
cavalry in the republican period, extended to 5,200 infantry and 120
auxilia in the imperial period.
Thus, there might have been 4000 to 5000 demons in the man if the legion is any indication. However, I would not press the number too literally, except what the record explicitly states, namely, that there were "many" (Mark 5:9).
I am sure that just a few demons would enough drive 2000 pigs over a cliff so I do not think that gives us any real indication of the number. The Roman legion is a better indicator but the exact number is not stated.
Ellicott suggests that there might have been perhaps 6000 (see his comment on Matt 8:29) -
“My name is Legion, for we are many.” The irresistible might, the full
array of the Roman legion, with its six thousand soldiers, seemed to
the demoniac the one adequate symbol of the wild, uncontrollable
impulses of passion and of dread that were sweeping through his soul.
It would hardly have seemed possible that the force of literalism
could have led any interpreter to infer the actual presence of six
thousand demons, each with a personality of His own, and to calculate
accordingly the number that must have entered into each of the two
thousand swine: and yet this has been done.
Barnes agrees with my comment above:
Mark and Luke say that Jesus inquired the name of the principal
demoniac, and that he called his name "Legion, for they were many."
The name legion was given to a division in the Roman army. It did not
always denote the same number, but in the time of Christ it consisted
of 6,000 to 3,000 foot soldiers and 3,000 horsemen. It came,
therefore, to signify "a large number," without specifying the exact