add pat codes: counting ones