esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

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.

11 min readIntermediateCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

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.

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.

Key words

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.

Why a letter count can go wrong

Adjuster's question

How often 'n' appears in a claim ref?

Before the model

Cut into chunks

letters hide inside the chunks

Model

predicts the next chunk of text

A count with no check

can sound sure and still be wrong

  1. 1The question goes in as plain text.
  2. 2The text is cut into chunks, so single letters hide inside them.
  3. 3The model writes a count from those chunks, and nothing checks it.
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.

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. 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. 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. 3

    Add with exact decimals

    Money is summed with exact decimals in code, so a total can avoid binary rounding errors.

  4. 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

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.

Two ways to get a total

14 invoice lines

the claim needs one exact total

Model adds in its head

One number, no check

can look right and be off

Code adds the amounts

Python sums exact pence

same lines, exact Decimal sum

Unchecked figure

goes into the claim unread

Checked total

matches the lines, then is used

  1. 1The lines go to the model, which adds them in its head.
  2. 2The same lines go to code that adds them with exact decimals.
  3. 3The model's number goes into the claim with no check.
  4. 4The code's total is compared with the invoice, then used.
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.

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."

    BetterScale 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."

    BetterResearchers still disagree on the cause. Test your own bot before you decide.

  • Trap"The model explained its steps, so the answer is right."

    BetterAn 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?

Quick check

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

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q003What is a token, and why not whole words?11 min
  2. Q004How do tokenizers like BPE, WordPiece and SentencePiece work?11 min
  3. Q005Why do token counts differ across languages and models?10 min
  4. Q027What is a reasoning ("thinking") model?11 min
  5. Q078What is chain-of-thought, and when does it help?10 min
  6. Q156What is tool (function) calling?11 min

Learn it in depth

Last updated on 26 November 2026

Building an AI assistant that has to get numbers right?

Venkat designs and builds AI products and agents, including the UI and the system behind it. Book a short call and say what you need.