So in episode "The Prisoner of Benda" broadcast in season 7, the staff switch minds but they can't switch back with each other, so they have to use MATH! Yes, that horrible thing... But to the point, how many people were needed for them to switch back? What was the formula which proves the theoretical number that was needed for everyone to return to their bodies?
Here is the formula used
However according to my research there is actually a small typo in the equation
"The proof contains a minor typo: instead of "For any i=1 ... k" it should read "For any i=1 ... k-1". The algorithm fails for i=k, but this does not affect the validity of the proof."
According to the Wikipedia entry only 2 extra people where needed to restore everyone back to their rightful bodies.
Finally, two Globetrotters, Ethan "Bubblegum" Tate and "Sweet" Clyde Dixon, mathematically prove that everyone's minds can be restored using two additional bodies and then successfully do so, with themselves as the extras.
You can always switch back to your original state by using two extra people. Use one Globetrotter to switch all but the last person, then use the second globetrotter to switch with the last person then switch the two globetrotters back to their original bodies.
I believe that they needed 11 people total. They were Bender, Fry, Leela, Amy, Professor Farnsworth, Ethan Bubblegum Tate, Clyde Dixon, Zoidberg, wash bucket, the Hungarian prince, and Hermes.