Answer:
28 lollipops.
Explanation:
Let's say that
is the total number of lollipops in the bag, which Matt won.
So, if Matt gave 21 lollipops to his friends, and he kept with 7 lollipops, that means there were 28 lollipops in the bag.
If we represent this as an equation, would be:

Where
is friend's lollipops, and
is Matt's lollipops.
Replacing values we have:

Therefore, in the bag were 28 lollipops in total.