In a tournament bracket, a player must be defeated three times to be eliminated. If there are 512 contestants entering the tournament, what is the greatest number of games that could be played?

Let's think step by step and output the final answer within \boxed{}.
user