Riley and her children went into a movie theater and she bought $51 worth of bags of popcorn and drinks. Each bag of popcorn costs $5 and each drink costs $6. She bought twice as many drinks as bags of popcorn. Determine the number of bags of popcorn and the number of drinks that Riley bought.

Let the number of bags of popcorn be represented by P and the number of drinks be represented by D.

Given:
5P + 6D = 51 (total cost of bags of popcorn and drinks)
D = 2P (twice as many drinks as bags of popcorn)

Substitute D = 2P into the first equation:
5P + 6(2P) = 51
5P + 12P = 51
17P = 51
P = 3

Now, substitute P = 3 back into D = 2P:
D = 2(3)
D = 6

Riley bought 3 bags of popcorn and 6 drinks.