Problem:
Score : 200 points

Problem Statement

Find the number of palindromic numbers among the integers between A and B (inclusive).
Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.

Constraints

10000 \leq A \leq B \leq 99999

All input values are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the number of palindromic numbers among the integers between A and B (inclusive).

Sample Input 1

11009 11332

Sample Output 1

4

There are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.

Sample Input 2

31415 92653

Sample Output 2

612

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <iostream>
#include <string>

int main() {
  /*
  int a, b, na, nb;
  int a1, a2, a3, a4, a5, b1, b2, b3, b4, b5;
  std::cin >> a >> b;
  
  b1 = b % 10;
  b2 = (b / 10) % 10;
  b3 = (b / 100) % 10;
  b4 = (b / 1000) % 10;
  b5 = (b / 10000) % 10;
  
  nb = 0
    + b5 * 10 * 10
    + b4 * 10
    + b3
    + (b4 >= b2 && b5 >= b1) ? 1 : 0;


  34243;
    
  2-*-2 )	-, *
  1-*-1 ) 	3 * 10 * 10
  0-*-0 )
  3			
   3*33 )
   2*23 )	4 * 10
   1*13 )
   0*03 )
   4
    143 )	2
    043 )
    2
  
  a--;
  a1 = a % 10;
  a2 = (a / 10) % 10;
  a3 = (a / 100) % 10;
  a4 = (a / 1000) % 10;
  a5 = (a / 10000) % 10;

  na = 0
    + a5 * 10 * 10
    + a4 * 10
    + a3
    + (a4 >= a2 && a5 >= a1) ? 1 : 0;
  
  std::cout << nb << std::endl;
  std::cout << na << std::endl;
  std::cout << nb - na << std::endl;
  */
  int sum = 0;
  int a, b;
  std::cin >> a >> b;
  for (int i = a; i <= b; i++) {
    int i1, i2, i3, i4, i5;
    i1 = i % 10;
    i2 = (i / 10) % 10;
    i3 = (i / 100) % 10;
    i4 = (i / 1000) % 10;
    i5 = (i / 10000) % 10;
    if (i1 == i5 && i2 == i4) {
      sum++;
    }
  }
  std::cout << sum << std::endl;
}