Build a bit-counting comparator using NAND logic gates
169 nands

Adds up the A's to get A{1,2,4,8,16}.  Then does a binary comparison with the Bs.

I use a few more building blocks:


FA = full adder, 9 nands (from here)
HA = half adder, 7 nands (same ref)
EQ = equality, 5 gates (a.k.a. xnor)


The half and full adders have 2 outputs - they are distinguished with an r for result and c for carry.

The A{1,2,4,8,16} are the outputs from the half adders.