Under construction

Still being built. Things may change

Palindrome Numbers

Interview

Time limit1sMemory limit1024 MB

Summary
Given n below 10^10, count the palindrome numbers from 1 to n inclusive.
Level

Easy3 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

For a positive integer PP, if the digits of PP read from left to right are the same as the digits read from right to left, PP is called a palindrome number. For example, 11, 101101, and 1232232112322321 are all palindrome numbers. Given a positive integer nn, write a program that prints the number of distinct palindrome numbers less than or equal to nn. For example, when n=20n = 20, there are 10 palindrome numbers up to 20 (11, 22, 33, 44, 55, 66, 77, 88, 99, 1111).

Input

The input is read from standard input. The first line contains a positive integer nn (1≤n<10101 ≤ n < 10^{10}).

Output

The output is written to standard output. Print the number of distinct palindrome numbers less than or equal to nn on one line.

Examples2

  1. Example 1

    Input
    20
    
    Expected output
    10
    
  2. Example 2

    Input
    101
    
    Expected output
    19