This equation is not true.
Let g be the number of grandchildren, and d be the number of dogs. They both have only one head, so the number of heads is

Grandchildren have 2 legs, while dogs have 4. So, the total number of legs is

From the first equation (the one for the heads) we can derive

Substitute this into the second to get

So, there are 9 dogs and (from the first equation

Grant can buy 3 packes of the 10 or he can put 30 packs of the single pieces