#P2110. Counting Numbers with Matching First and Last Digits

    ID: 15392 Type: Default 1000ms 256MiB

Counting Numbers with Matching First and Last Digits

Counting Numbers with Matching First and Last Digits

It is known that certain numbers are special because their first digit is equal to their last digit in decimal representation. Given two integers \(L\) and \(R\), count the number of integers \(X\) such that \(L \le X \le R\) and the first digit of \(X\) is the same as its last digit.

For example, numbers like 2, 101, and 329873 are valid because the first and last digits match, while 23 and 4567 are not.

This problem is inspired by an old verse from the Classic of Poetry and a tale of love. Help Huan prove his sincerity by solving this challenge!

inputFormat

The input consists of a single line containing two space-separated integers \(L\) and \(R\).

outputFormat

Output a single integer: the count of numbers in the range \([L, R]\) whose first and last digits are the same when written in decimal form.

sample

1 9
9