2 electrons in the first shell for each carbon. Then four in the second shell(this is why it sustains four bonds; needs four more to be in the octet state). So 6 from each carbon, then one from each hydrogen. =12
Think of it like kids and toys. Each kid wants to have as many toys as the cool kids at the end of their street(the noble end, lol) So they meet up with each other and agree to share some toys. They each act as though they have a full shell but really between them they only have the same number that they started with. (EDIT: ie. the sum of the atomic numbers.)
(That is unless one of the bigger kids(non-metals) bullies a little(less electronegative) kid into giving him one for good. ie. ionic bonding)
Um, examples..
O2 - How many electrons? There's 16, not 20, because of the double bond.
N2 - There's 14, not 20, due to the triple bond.
CO2 - There's 22, not 30, because of the two double bonds.