A bakery sells cupcakes for $2 each and cookies for $1 each. On a particular day, the bakery sells a total of 50 items, which consists of both cupcakes and cookies. How many cupcakes did the bakery sell if it sold twice as many cookies as cupcakes?