Let C be the number of pencils and S the number of pens that Anthony bought.
Since a total of 12 pens and pencils were bought, then:

Since Anthony spent $2.80 and each pen costs $0.35 while each pencil costs $0.15, then:

Since we want to know S (the number of pens that Anthony bought), isolate C from the first equation:

Substitute C=12-S into the second equation:

Use the distributive property to rewrite 0.15(12-S) as 0.15*12-0.15S:

Sum alike terms on the left hand side of the equation:

Multiply 0.15*12:

Substract 1.80 from both sides of the equation:

Simplify the sum on the right hand side of the equation:

Divide both sides by 0.20:

Simplify the fraction:

Therefore, Anthony bought 5 pens.