# Why Do LLMs Struggle to Count Letters or Do Arithmetic?

> Why models miscount letters and slip on sums, how tokens and digit places cause it, and what to do, explained simply for your AI interview.

**In short:** LLMs read text in chunks called tokens, so letters and digits are hidden inside them. They also generate text by prediction, so exact counts and long sums can slip. Letting the model run Python gives an answer you can check.

AI and LLM interview question Q035, LLM fundamentals. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/why-do-llms-struggle-to-count-letters-or-do-arithmetic

## Say it in 30 seconds

LLMs read text in chunks called tokens, so the model often can't count each letter or digit reliably. It also works by prediction, so counts and long sums can slip. That's why I don't trust a model's own maths. I let the model pull the numbers out, let code do the exact count or sum, and have a person check any total that gets paid.

## Say it in 2 minutes

A language model reads text in tokens. A token can be a whole word, part of a word, a symbol or a single letter, and the model works with those tokens. So a question about how many 7s sit in a policy number has to be answered from chunks the model rebuilds as it goes.

Arithmetic has the same problem with digits. Long numbers are split into chunks, and the model has to keep track of where each digit sits, which is easy to lose across a long number. Researchers still argue about the main cause, so I don't blame tokenization alone. I test the bot on repeated letters and long numbers to see where it breaks.

The fix is to split the work. The model pulls the amounts out of the text, and code adds them with exact decimals and counts the letters exactly. The model can then explain the result, and a person checks any total that is going to be paid.

So in an interview I say it plainly. A model can read and explain numbers, but exact counts and sums belong in code, and the risky totals get checked by a person. That is the answer I would defend to a client.

## Why do LLMs struggle to count letters or do arithmetic, in plain words?

An LLM does not see your text as letters first. It cuts the text into tokens, and OpenAI's help page says: "A token can represent a character, part of a word, a whole word, or punctuation." For example, a word like reimbursement may be cut into several pieces, so its letters are split across them.

Anthropic's glossary explains that a language model is "pretrained to predict the next word, given the previous context of text in the document." So it writes its answer one token at a time, each one predicted from what came before. Exact counting and adding need exact steps, and a prediction alone gives no such steps.

Think of a claims clerk who gets a fax where every word is cut into strips. They can read the words, but counting the letters on one strip means seeing it whole. The model is in the same spot. It works with the strips and has to guess at the letters inside them.

Real case: a policy-lookup bot is asked how many 7s appear in a policy reference. The reference reaches the model as chunks, so the bot must rebuild the digits before it can count them, and the count stays a guess until someone checks it.

- **Token:** A chunk of text the model reads: a whole word, part of a word, a symbol or one letter.
- **Tokenizer:** The tool that cuts text into tokens before the model sees it.
- **Next-token prediction:** The model guesses the next chunk, then the one after, until it stops.
- **Carry:** In addition, the 1 that moves left when a column adds to 10 or more.

## Why can't the model count the letters reliably?

A 2025 paper, The Strawberry Problem, calls tokenization a fundamental limitation. A 2024 study by Fu and colleagues found that models can spot letters but miscount them. Fu and colleagues say several earlier works linked the problem to tokenization, the limits of attention, or missing character-level training data. Researchers still argue about the main cause, so treat tokenization as one strong suspect and test your own bot.

> "consistently fail at simple character-level tasks, such as counting letters in words, due to a fundamental limitation: tokenization" (The Strawberry Problem paper, arXiv 2025)
>
> "models are capable of recognizing the letters but not counting them" (Fu and colleagues, arXiv 2024)

Fu and colleagues also found that errors track the number of letters or tokens in a word, and that the strongest link is with letters that appear more than once in the word. So test your own bot on words with repeated letters before you decide on a cause. These papers date from 2024 and 2025. Newer models may do better, so check again on whatever model you use.

*Diagram, Why a letter count can go wrong: A question about letters reaches the model as chunks of text. The model predicts its count from those chunks. Nothing in the chain checks the number.*
1. The question goes in as plain text.
2. The text is cut into chunks, so single letters hide inside them.
3. The model writes a count from those chunks, and nothing checks it.

## Why is arithmetic harder?

Numbers get chunked too. Singh and Strouse (2024) tested GPT-3.5 and GPT-4 on arithmetic. Those models have separate tokens for each 1-, 2- and 3-digit number, so a long number arrives in pieces whose place value is easy to lose.

Their study found that right-to-left tokenization, forced by commas, led to largely improved performance. The gap between the two directions got smaller as the models grew, so the size of the effect depends on the model.

> "The poor performance of transformers on arithmetic tasks seems to stem in large part from their inability to keep track of the exact position of each digit inside of a large span of digits." (McLeish and colleagues, arXiv 2024)
>
> "Instead, we find that Claude employs multiple computational paths that work in parallel." (Anthropic research on Claude)

That study tested transformers on arithmetic tasks, so treat it as a clue about LLMs and test your own model.

Anthropic's research on Claude found that addition runs on several paths at once. Asked how it figured out that 36 + 59 is 95, the model described the standard algorithm involving carrying the 1. Anthropic says Claude seems unaware of the sophisticated mental math strategies it learned during training.

Worked example: a claims bot must total 14 invoice lines on a water-damage claim. The model is useful for pulling the amounts out of the text. Adding 14 numbers in one reply leaves no step anyone can check, so the total goes to code.

## How do you get an exact count or sum?

1. **Let the model call code:** OpenAI's Code Interpreter lets a model write and run Python in a sandbox for maths and data work. The code does the exact part, and the model only sets it up.
2. **Pull the numbers out first:** Ask the model to list each amount as plain text. Code then reads that list, so every number can be checked against the source.
3. **Add with exact decimals:** Money is summed with exact decimals in code, so a total can avoid binary rounding errors.
4. **Compare and flag:** Check the code's total against the invoice's own total. If they differ, the claim goes to a person.

Here is the split in plain Python. The model pulls the numbers out, and the code does the exact work. Run it and you get the same answer every time.

```python
# A claims bot's check: the model reads the numbers out; code does the exact sum and the exact count.
from decimal import Decimal

# First five of the 14 invoice lines on one water-damage claim, as the model pulled them out (amounts as text).
lines = ["1284.50", "96.75", "310.00", "42.25", "18.99"]
note = "Water damage to the kitchen floor, and water stains on the ceiling."

# Decimal keeps money exact. Floats can be off in the last digit: 0.1 + 0.2 gives 0.30000000000000004 in Python.
total = sum(Decimal(amount) for amount in lines)
print("Invoice total:", total)

# Counting is exact in code, so the model never has to guess. split() misses words with punctuation, such as water,
print("Letter r in the note:", note.lower().count("r"))
print("Word water in the note:", note.lower().split().count("water"))
```

Output:

```text
Invoice total: 1752.49
Letter r in the note: 3
Word water in the note: 2
```

> **Tip:** For a sum inside a prompt, comma-separate the big numbers. In Singh and Strouse's tests on GPT-3.5 and GPT-4, right-to-left tokenization forced by commas largely improved arithmetic. Newer tokenizers may differ, so test your own model.

*Diagram, Two ways to get a total: Two ways to get the total for the same 14 lines. In the first, the model's number goes straight into the claim. In the second, code adds the lines exactly and the total is checked before use.*
1. The lines go to the model, which adds them in its head.
2. The same lines go to code that adds them with exact decimals.
3. The model's number goes into the claim with no check.
4. The code's total is compared with the invoice, then used.

### How would you build a claims bot that must get totals right?

The bot reads the invoice, then must give one total the claim can be paid on. Build it so no total leaves the system unchecked.

- **Without code: The number goes in unchecked.** The model adds the lines and the claim moves forward on its figure.
- **With code: The sum is checked first.** Code adds the lines, and any mismatch goes to a person before payment.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain reason: the model reads chunks of text, and it predicts its answer.
- [ ] Tokens, with one example of how a word or number gets cut.
- [ ] Why sums are hard: digits come in chunks, and place value is easy to lose.
- [ ] No single cause is settled, and you say so.
- [ ] The fix: code counts and adds, the model pulls out and explains, a person checks the risky totals.
- [ ] Testing the bot on a range of repeated letters and long numbers.

**Common traps**

- Trap: "A bigger model will count letters correctly." Better: Scale narrowed the gap in one study, but a bigger model is still no guarantee. Give the count to code.
- Trap: "It is only tokenization, so fix the tokenizer." Better: Researchers still disagree on the cause. Test your own bot before you decide.
- Trap: "The model explained its steps, so the answer is right." Better: An explanation is not proof. Anthropic found Claude can describe the carry method while working another way. Check the number.

## Can you pick the safe design?

**Spot the risk:** A claims bot replies: 'The 14 lines total 3,918.25.' What proves that number?

A. Reading the reply aloud to the adjuster
B. Adding the 14 amounts again in code and comparing
C. Checking that the reply sounds polite
D. Asking the bot the same question in a new chat

**Answer:** B. Only an exact sum in code, set against the invoice lines, proves the total. Reading the reply or asking again only repeats the guess.

**Quick check:** A bot must count how often 'refund' appears in 40 pages of chat logs. What is the safest design?

A. Ask the model to count, then trust the number
B. Let the model read the pages and estimate the count
C. Have code count the word, and let the model explain the matches
D. Use a bigger model with a longer prompt

**Answer:** C. Counting is exact work, so code does it. The model is well suited to reading the matches and explaining them.

## Can you answer these from memory?

**Flash cards**

- **What is a token?** A chunk of text the model reads: a word, part of a word, a symbol or one letter.
- **Why can't a model count letters reliably?** It reads chunks of text and predicts its answer, so a count can be a guess.
- **Why are long sums hard?** Digits come in chunks, and the model must keep track of each digit's place.
- **Is tokenization the whole cause?** Not settled. Papers disagree, so test your bot on repeated letters and long numbers.
- **What is the fix?** Code counts and adds exactly. The model pulls out the numbers and explains the result.
- **Does a model's explanation prove its method?** No. Anthropic found Claude described carrying while its inner work ran on parallel paths.

## Likely follow-up questions

- Q003 What is a token, and why not whole words? https://designervenkat.online/interview/ai/what-is-a-token
- Q004 How do tokenizers like BPE, WordPiece and SentencePiece work? https://designervenkat.online/interview/ai/how-do-tokenizers-work-bpe-wordpiece-sentencepiece
- Q005 Why do token counts differ across languages and models? https://designervenkat.online/interview/ai/why-do-token-counts-differ-across-languages-and-models
- Q027 What is a reasoning ("thinking") model? https://designervenkat.online/interview/ai/what-is-a-reasoning-model
- Q078 What is chain-of-thought, and when does it help? https://designervenkat.online/interview/ai/what-is-chain-of-thought-prompting
- Q156 What is tool (function) calling? https://designervenkat.online/interview/ai/what-is-tool-calling

## Learn it in depth

- [Tokenization](https://designervenkat.online/learn/machine-learning/tokenization)
- [Tokens](https://designervenkat.online/learn/ai-engineering/tokens)
