Per SageAdvice (https://www.sageadvice.eu/2017/12/15/is-freedom-of-movement-broken/)
"Is Freedom of Movement Broken? It doesn't seem to help a Grappled or
Restrained creature, at all. It this a mistake or working as intended?
if your speed is 0, how do you expend 5 feet of movement?" -Keith
"Freedom of movement is an example of a feature (an exception) that
lets you circumvent a general rule; it lets you spend 5 feet of
movement to escape a grapple, even though your speed is 0. Magic!"
There was a follow up question to this:
"So under freedom of movement, a creatures speed can be reduced to 0
(non-magically) but they are able to suspend 5ft to escape? So after
that, (if in init.) their speed would still be zero for that turn?"
"If you escaped the grapple, your speed isn’t 0 any longer." -Jeremy
With that question and answer, I guess it means that you can spend 5ft of movement, as many times as needed, to escape a grapple.
Per the spell:
The target can also spend 5 feet of movement to automatically escape
from nonmagical restraints, such as manacles or a creature that has it
This means that if you need to escape from 1 grapple you will have 25 movement (assuming 30 movement to start). If you need to escape from 4 grapples you will have 10 movement. If you need to escape from 6 grapples you will have 0 movement. And most importantly, if you need to escape from 7 or more grapples you will still have 0 movement (but you can still spend movement to escape from them).