問題一覧 > 通常問題

No.491 10^9+1 and Palindromes

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 64 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 150
作問者 : e869120 / テスター : square1001
お気に入りにしたユーザー ProblemId : 1284 / 自分の提出
問題文最終更新日: 2026-06-25 08:26:11
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 158 (順位表) の他の問題:

Problem Statement

5 000 000 005 is a multiple of $10^9+1$ and a palindrome.

You are given an integer N. Find the number of integers between 1 and N, inclusive, that are multiples of $10^9+1$ and palindromes.

Here, a palindromic number is a number that reads the same from right to left as from left to right, such as "969", "3223", and "1".

Input

N

The first line contains an integer $N(1 \le N \le 10^{18})$.

Output

Output on one line the number of integers between 1 and N, inclusive, that are multiples of $10^9+1$ and palindromes. Print a newline at the end.

Sample

Sample 1
Input
4000000000
Output
3

1000000001,2000000002,3000000003 satisfy the conditions.

Sample 2
Input
40000000000
Output
12

There are 12 such numbers: 1000000001,2000000002,3000000003, 4000000004,5000000005,6000000006, 7000000007,8000000008,9000000009, 11000000011,22000000022,33000000033.

Sample 3
Input
1000000007
Output
1

One billion and seven!

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。