Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.

book
Ordinary Numbers

A positive integer n is called ordinary if all its digits in decimal notation are the same. For example, 1, 2, and 99 are ordinary numbers, while 719 and 2021 are not.

Given a number n, count how many ordinary numbers exist between 1 and n.

Example 1

Input:

100

Output:

18

Example 2

Input:

5

Output:

5
main.cpp

main.cpp

C++

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

some-alt