For how long can you count your breaths?

Not sure if this is the right forum, but it is hard to figure out what is.

A couple nights ago while lying in bed and not sleeping, I decided to count my breaths. So I started counting. By the time I got to 30, I had started to think of something else and lost count. I tried again. Same result. I have tried several times since. No matter how many times I have resolved not to lose the thread, I have not succeeded in getting to 50. Mostly my mind (what there is of it anyway) starts wandering between 20 and 30, although I once got to 40. Despite my best resolve. It makes me wonder: Who’s in charge here? A cognitive psychologist might say that nobody is. “I” am just a caucus of contending voices. Or is this a sign of incipient dementia?

How far can you go? And if you can keep it up indefinitely, have you ever studied meditation?