Skip to content

Why AI can't count the letters in a word

The short answer

Your text is cut into tokens before the model reads it, and a token is usually a chunk of several letters — inside a normal sentence, strawberry is one single token. Counting letters means counting inside something the model was never shown, so it answers from the shape of similar text instead of by looking. Separating the letters is what actually fixes it.

how many r’s are in “strawberry”?

what you see — ten letters
strawberry

three r’s, plain as day

what the model reads — one sealed piece
strawberry

inside a sentence this is a single token — the letters are not visible from the inside

the fix — separate the letters
strawberry

ten tokens now — each letter is something the model can look at

Counting letters means counting inside something it was never shown. It answers from the shape of similar text — separating the letters is what actually fixes it.
What the model actually reads

Your text cut into the pieces a model actually reads. In the o200k_base encoding, strawberry on its own becomes 3 tokens — st, raw, berry — and inside a full question it is a single token. The ten separate letters are never shown to the model.

What’s actually happening

A model never receives your text. It receives a list of numbers. OpenAI’s own tokenizer repository puts it plainly — language models:

see a sequence of numbers (known as tokens)
openai/tiktoken — What is BPE anyway?

Those numbers stand for chunks of text, not for letters. The chunking is learned from data, so frequent words end up as a single chunk and rare ones get split. OpenAI’s tokenizer guide says tokens in English “commonly range in length from one character to one word”.

Run strawberry through the demo above and you get three chunks — st, raw, berry. Now put the same word inside a real question, the way you would actually type it:

How many r are in strawberry?

That is seven tokens in total, and the word itself is one of them. The model is handed a single number that means “the word strawberry” and asked how many of a letter are inside it. The letters are not in the input at all.

So the model does what it does with everything else: it produces the continuation that usually follows such a question. Text on the internet about counting letters is full of small numbers, and “two” is a very ordinary answer. It is a guess dressed as arithmetic — not a lie, and not bad maths. It is an answer about something the model was never shown.

This is also why the failure looks so strange next to everything else the model can do. Summarise a contract, and the units it works with — words, clauses, ideas — survive tokenization intact. Ask about the letters inside one word, and you are asking about the one thing tokenization throws away.

What to do about it

Break the word apart yourself. Type s t r a w b e r r y or s-t-r-a-w-b-e-r-r-y instead of strawberry. Both forms become ten tokens, one per letter, so the letters are finally visible. You can check this in the demo above: paste the spaced version and count the boxes.

Ask for the work, not the number. “List the letters of strawberry with their positions, then count the r” turns an invisible question into a visible one. Models that reason before answering often perform this trick internally, which is why the same question sometimes succeeds — but it is not something you can rely on.

Use a real tool for character-level work. Counting characters, finding every occurrence of a string, checking a password length: your text editor does this exactly and instantly. Nothing is gained by routing it through a model.

Treat any character-level claim as unverified. “This string is 32 characters”, “there are no double letters here”, “this ends in -ing” — all of these are answers about the invisible layer. Check them.

Two tools on this site run the same tokenizer as the demo above, on your own text: Token counter shows the split and the count for a piece of text, and Context fit does the same arithmetic for a whole document against a model’s context window. Same unit, different question.

Common questions

1 Is the model lying when it says there are two r in strawberry?
No. It is answering about something it cannot see. The word arrives as one or three numbered chunks, not as ten letters, so there is nothing to count. A wrong count here is the same kind of mistake as guessing the number of pages in a book from its title.
2 Why does it sometimes get it right?
Because a model can work around the problem the same way you can force it to: by writing the word out letter by letter first. Spaced or hyphenated letters become one token each, and once they are separate tokens they can be counted. Models that think step by step before answering often do this on their own — which is why the same question can succeed one day and fail the next.
3 Do all models split words the same way?
No. The split depends on the encoding, and encodings differ. In OpenAI's o200k_base, strawberry alone is st + raw + berry. Anthropic and Google have not published the tokenizers for their current models at all, and OpenAI's own model-to-encoding map ends at GPT-5, so for anything outside it the honest answer is an estimate, not a split — our token counter marks it as such.

Related

Sources

Last checked: