Counting is one of the algorithms that can be expressed by a RASP program, which transformers closely approximate.