#CCBOTPBA0000060. Đếm số đối xứng trong đoạn (Count Palindromic Numbers in an Interval)

Đếm số đối xứng trong đoạn (Count Palindromic Numbers in an Interval)

Count Palindromic Numbers in an Interval

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

A non-negative integer is palindromic if its decimal digits read the same left to right and right to left. For example, 00, 77, 1111, and 121121 are palindromic, but 1212 and 120120 are not. Given integers LL and RR with L≤RL\le R, count palindromic integers in the inclusive interval [L,R][L,R]. Zero is palindromic.

Input

One line contains two integers LL and RR, in this order.

Output

Print one integer: the count of palindromic integers in [L,R][L,R].

Subtasks

  • Subtask 1 (20%): 0≤L≤R≤10000\le L\le R\le 1000.
  • Subtask 2 (30%): 0≤L≤R≤100000\le L\le R\le 10000.
  • Subtask 3 (50%): 0≤L≤R≤2000000\le L\le R\le 200000.

Examples

Example 1

Input:

0 11

Output:

11

Explanation: The ten values 0 through 9 are palindromic. 10 is not; 11 is. Therefore the total is 10 + 1 = 11.

Example 2

Input:

120 123

Output:

1

Explanation: Reversing 120, 121, 122 and 123 gives 21, 121, 221 and 321. Only 121 is palindromic, so the answer is 1.

Example 3

Input:

0 0

Output:

1

Explanation: The interval contains only zero, whose single digit is unchanged when reversed. The answer is 1.