<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_all(gset, elem):
 """Removes every occurrence of ``elem`` from ``gset``. Returns the number of times ``elem`` was removed. """

    n = 0
    while True:
        try:
            remove_once(gset, elem)
            n = n + 1
        except RemoveError:
            return n