Counting and Algorithmic Generalization with Transformers