Press Esc to close

Why AI chatbots can't count the r's in strawberry, and why it matters

Why AI chatbots can't count the r's in strawberry, and why it matters
Chart of processing time against tokenization length by language

Image: Petrov et al., NeurIPS 2023

Ask an AI chatbot how many times the letter r appears in the word strawberry, and for a long time the answer was surprisingly likely to be wrong. The right answer is three. Many models failed to get it, and the strawberry question turned into one of the most widely shared examples of how a system that can write essays and solve maths problems can still trip over something a child can do.

Researchers have since studied the problem closely. A research team that includes Javier Conde and Pedro Reviriego described it in a 2024 paper as an illustration of "the inability of many LLMs to count the number of 'r' letters in 'strawberry'". LLM stands for large language model, the technology behind chatbots such as ChatGPT, Gemini, Claude and Grok. The reasons behind the mistake say a lot about how these tools read text, and they also explain why using AI in Hindi or Tamil can cost more than using it in English.

The starting point is that a chatbot does not read words letter by letter the way people do. Before any text reaches the model, a piece of software called a tokenizer chops it into chunks called tokens. A token can be a whole word, part of a word, a single character or a punctuation mark. The model only ever sees these tokens, each turned into a number, and its job is to predict which token should come next.

OpenAI offers a public tokenizer tool that shows how its models split text. A figure in a paper by Conde, Reviriego and colleagues, published in the IEEE magazine Computer, shows the tool splitting strawberry for GPT-4o into three pieces, st, raw and berry. OpenAI's open source tiktoken library, which contains the same o200k_base tokenizer used by GPT-4o, produces the same split for the word on its own. When the word appears inside a sentence after a space, the same tokenizer treats it as a single token.

How GPT-4o splits strawberry into tokens

Image: Conde et al., IEEE Computer

From the model's point of view, then, the question is not about ten letters. It is about two or three chunks, and to count the r's it would need to know that st has none, raw has one and berry has two. That information is not written anywhere in the numbers the model receives. It has to be learned indirectly from the patterns in its training data.

Splitting text into chunks is a deliberate design choice, and it saves a great deal of work. The Conde paper explains that chatbots generate answers one token at a time, and each step carries a large computing cost. In one example in the paper, an answer that would take 25 predictions if the model worked letter by letter took only 6 predictions with GPT-4o's tokens. The authors describe it as a trade off. Using single letters would need too many predictions, while giving every word its own token would need too many distinct tokens. According to the paper, GPT-4o has roughly 200,000 distinct tokens, and common letter sequences get their own tokens because they appear so often.

It is tempting to blame tokenization for the whole problem, but the research suggests the picture is more nuanced. The 2024 study tested a group of models on a large number of words and found that the models are capable of recognising the letters but not counting them. It also found that how common a word or its tokens are in training data did not have a significant impact on the errors.

What did matter was the structure of the word. The researchers found that errors rose with the number of letters or tokens in a word, and that more frequent letters tended to produce more counting mistakes. The strongest link was with letters that appear more than once, and most models were unable to correctly count words in which a letter appears more than twice. Strawberry, with its three r's, two of them side by side, falls squarely into that difficult category.

A separate 2024 paper on counting in large language models points to a deeper limit. Its authors explain that transformers, the architecture behind modern chatbots, are confined to a fixed amount of computation per step, while counting requires the reasoning to grow with the length of the input. The paper notes that chain of thought, where a model works through a problem step by step, can help ease some of these limits, and it reports substantial differences in counting performance depending on how the input is tokenized.

Models do get better at this, though slowly. A 2025 paper titled The Strawberry Problem trained models on 19 synthetic tasks that isolate character level reasoning. The authors found that such abilities emerge suddenly and only late in training, and they argue that learning how words are built from letters is not fundamentally different from learning commonsense knowledge. They also propose a lightweight change to model design that significantly improves character level reasoning while keeping the advantages of subword tokens.

Training aimed at the task itself also works. In the Conde study, GPT-4o miscounted the r's in 1,188 of 7,790 English words, a failure rate of 15.25 percent. After fine tuning, which means further training on a smaller set of examples, the failure rate on a separate set of 7,790 test words fell to 0.74 percent. The fine tuned model also made fewer mistakes when counting the letters a and m, even though it had only been trained on r. The authors point out that counting letters has little practical value on its own, since an ordinary computer program can do it, but say the exercise shows how these models process text and learn.

That point hints at the most reliable fixes in everyday use. Newer reasoning modes let a model write out its thinking before answering, which matches the step by step approach the counting research describes as helpful. Many chatbots can also run code, and a one line program can count letters exactly every time, sidestepping tokens altogether.

The same chunking that trips up letter counting has a more serious side effect for many Indian users. In a paper presented at NeurIPS 2023, Aleksandar Petrov and colleagues at the University of Oxford compared how many tokens different tokenizers need for the same text translated into about 200 languages. They found that the same text can have drastically different lengths, with differences of up to 15 times in some cases.

For the cl100k_base tokenizer used by ChatGPT and GPT-4 at the time, the paper reports that Italian needed about 1.6 times as many tokens as English, Bulgarian 2.6 times and Arabic 3 times. The appendix tables show far bigger gaps for Indian languages. Hindi needed about 4.8 times as many tokens as English for the same content, Marathi about 5.1 times, Tamil about 7.7 times, Telugu about 8.3 times, Kannada about 8.9 times, Malayalam about 9 times and Odia about 12.5 times. These figures apply to that older tokenizer. Newer models use different tokenizers, and the gaps may have changed since.

The authors list three consequences. The first is cost. Commercial AI services often charge per token, so a longer token count means a bigger bill for the same task. The paper says users of some languages pay at least 2.5 times more than English users, and that processing text in the most expensive languages for ChatGPT and GPT-4, such as Odia, costs more than 12 times as much as in English.

The second is speed. More tokens take longer to process, and the paper found that processing time grew in line with token length. In its tests, Shan took almost twice as long as English, and Tamil sat near the slow end of the chart. The third is the context window, the maximum amount of text a model can handle at once. Because that limit is counted in tokens, a language that needs more tokens fits less content into the same window. The paper estimates that users of languages such as Burmese and Dzongkha could fit less than a tenth of the content that English users could. The authors argue that future models should be trained with tokenizers designed to treat languages more fairly.

For everyday users, the practical lessons are simple. If an exact count of letters matters, ask the chatbot to spell the word out one letter at a time first, or ask it to use code to count. Treat any exact character or word count from a chatbot with caution, including limits for tweets, forms or headlines. And for anyone paying for AI by the token or hitting length limits, the language of the text can change both the bill and how much the model can take in at once.

The strawberry mistake looks like a harmless joke, but it comes from the same design choice that shapes what AI costs and how well it works for speakers of different languages. Fine tuning, reasoning modes and code tools can work around the counting problem, but at the time of this writing the published research still describes tokens, not letters, as the way these models read text.

Comments

Reader support

No ads. Just independent reporting.

Techcity Authority runs without advertising. Hosting, tools, and the hours behind each piece are supported by readers instead. Even a small contribution goes a long way — and every supporter is credited by name below for the month they give.

Support the site

Monthly via PayPal · cancel anytime

Secure checkout on PayPal. Your name appears here for the month you support.

This month’s supporters

    No supporters yet this month — yours could be the first name here.