About 50 people were invited to a potluck. Each invitee was required to bring an equal number of homemade cookies to the potluck.
In the potluck, 1287 cookies brought by the guests were poured into the pot and shuffled. The cookies were then distributed equally among all the guests present. No cookies were broken.
Sam was one of those who completely forgot about bringing cookies to the potluck. About 20 people with cookies had arrived at the potluck before him. How many cookies did Sam get?