AtCoder Beginner Contest 090 - Palindromic Numbers

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-----
11009 11332

-----Sample Output-----
4

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

Difficulty: EASY

Starter code:

Solutions:
(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	c = str(i)
	l = len(c)
	d = l // 2
	cnt = 0
	for i in range(d):
		if c[i] == c[-i - 1]:
			cnt += 1
	if cnt == d:
		ans += 1
print(ans)


(s, e) = list(map(int, input().split()))
print(len([i for i in range(s, e + 1) if str(i) == str(i)[::-1]]))


(A, B) = map(int, input().split())
k = 0
for i in range(A, B + 1):
	if i == int(str(i)[::-1]):
		k += 1
print(k)


(A, B) = map(int, input().split())
count = 0
for i in range(A, B + 1):
	count += str(i) == str(i)[::-1]
print(count)


(a, b) = map(int, input().split())
cnt = 0
for i in range(a, b + 1, 1):
	i = str(i)
	if i[0] == i[4] and i[1] == i[3]:
		cnt += 1
	else:
		continue
print(cnt)


(a, b) = map(int, input().split())
c = 0
for i in range(a, b + 1):
	if str(i) == str(i)[::-1]:
		c += 1
print(c)


(a, b) = map(int, input().split())
res = 0
for i in range(a, b + 1):
	s = str(i)
	res += s == s[::-1]
print(res)


(a, b) = map(int, input().split())
count = 0
for s in range(a, b + 1):
	if str(s) == str(s)[::-1]:
		count += 1
print(count)


(a, b) = map(int, input().split())
print(sum([str(i) == str(i)[::-1] for i in range(a, b + 1)]))


(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	ir = str(i)
	if ir == ir[::-1]:
		ans += 1
print(ans)


(a, b) = map(int, input().split())
c = 0
while a <= b:
	if str(a)[::-1] == str(a):
		c += 1
	a += 1
print(c)


(a, b) = map(int, input().split())
x = 0
for i in range(a, b + 1):
	if str(i)[:2] == str(i)[3:5][::-1]:
		x += 1
print(x)


(A, B) = input().split()
N = 0
for i in range(int(A), int(B) + 1):
	if str(i) == str(i)[::-1]:
		N += 1
print(N)


(a, b) = map(int, open(0).read().split())
print(sum((str(i) == str(i)[::-1] for i in range(a, b + 1))))


(A, B) = map(int, input().split())
count = 0
for i in range(A, B + 1):
	num = str(i)
	if num[0] == num[4]:
		if num[1] == num[3]:
			count += 1
print(count)


(A, B) = list(map(int, input().split()))
ans = 0
for i in range(A, B + 1, 1):
	x = list(str(i))
	if x[0] == x[4] and x[1] == x[3]:
		ans += 1
else:
	print(ans)


(A, B) = map(int, input().split())
num = 0
for n in range(A, B + 1):
	N = list(str(n))
	if N == N[::-1]:
		num += 1
print(num)


(a, b) = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
	x = str(i)
	if x[:3] == x[4:1:-1]:
		cnt += 1
print(cnt)


(n, m) = map(int, input().split())
c = 0
for i in range(n, m + 1):
	s = str(i)
	if s == s[::-1]:
		c = c + 1
print(c)


(a, b) = input().split()
a = int(a)
b = int(b)
c = 0
for i in range(a, b + 1):
	i = str(i)
	if i[0] == i[4] and i[1] == i[3]:
		c += 1
print(c)


(a, b) = map(int, input().split())
count = 0
for i in range(1, 10):
	for j in range(10):
		for k in range(10):
			if a <= 10000 * i + 1000 * j + 100 * k + 10 * j + i <= b:
				count += 1
print(count)


(A, B) = map(int, input().split())
print(len([i for i in range(A, B + 1) if str(i) == str(i)[::-1]]))


(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	if i % 10 == i // 10000 and i // 10 % 10 == i // 1000 % 10:
		ans += 1
print(ans)


(a, b) = map(int, input().split())
count = 0
for i in range(a, b + 1):
	if list(map(int, list(str(i)))) == list(reversed(list(map(int, list(str(i)))))):
		count += 1
print(count)


(a, b) = map(int, input().split())
c = 0
for i in range(a, b + 1):
	s = str(i)
	t = s[::-1]
	c += s == t
print(c)


(A, B) = [int(i) for i in input().split()]
print(sum([1 for i in range(A, B + 1) if str(i) == str(i)[::-1]]))


(a, b) = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
	i = str(i)
	if i[0] == i[-1] and i[1] == i[-2]:
		cnt += 1
print(cnt)


(lo, hi) = map(int, input().rstrip('\n').split())
print(sum([str(i) == str(i)[::-1] for i in range(lo, hi + 1)]))


(A, B) = map(int, input().split())
ans = 0
for x in range(A, B + 1):
	ans += str(x) == str(x)[::-1]
print(ans)


a = input()
a = a.split()
c = 0
for i in range(int(a[0]), int(a[1]) + 1):
	j = str(i)
	if str(i) == j[::-1]:
		c += 1
print(str(c))


(A, B) = map(int, input().split())
ans = 0
for i in range(A, B + 1):
	num = str(i)
	if num[0:2] == num[::-1][0:2]:
		ans += 1
print(ans)


(A, B) = map(int, input().split())
print([str(x) == str(x)[::-1] for x in range(A, B + 1)].count(True))


(A, B) = list(map(int, input().split()))
ans = 0
for n in range(A, B + 1):
	if str(n) == str(n)[::-1]:
		ans += 1
print(ans)


(A, B) = map(int, input().split())
n = 0
for i in range(A, B + 1):
	s = str(i)
	if s[0] == s[4] and s[1] == s[3]:
		n += 1
print(n)


(A, B) = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
	s = str(i)
	half = len(s) // 2
	add = len(s) % 2
	if s[0:half] == s[half + add:][::-1]:
		cnt += 1
print(cnt)


(a, b) = map(int, input().split())
c = list(range(a, b + 1))
print(len([c_ for c_ in c if str(c_)[4:2:-1] == str(c_)[:2]]))


(a, b) = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
	(l, r) = (list(str(i))[:3], list(str(i))[2:][::-1])
	if l == r:
		cnt += 1
print(cnt)


(a, b) = map(int, input().split())
ans = 0
for i in range(a // 10000, b // 10000 + 1):
	for j in range(0, 10):
		for k in range(0, 10):
			x = i * 10001 + j * 1010 + k * 100
			if a <= x <= b:
				ans += 1
print(ans, flush=True)


(a, b) = map(int, input().split())
print(sum(map(lambda x: 1 if str(x) == str(x)[::-1] else 0, range(a, b + 1))))


(a, b) = map(int, input().split())
print(len([i for i in map(str, range(a, b + 1)) if i == i[::-1]]))


(a, b) = list(map(int, input().split()))
ans = 0
for i in range(a, b + 1):
	s = str(i)
	ok = True
	for j in range(2):
		ok = ok and s[j] == s[4 - j]
	if ok:
		ans += 1
print(ans)


(A, B) = map(int, input().split(' '))
num = 0
for x in range(A, B + 1):
	if str(x) == str(x)[::-1]:
		num += 1
print(num)


(A, B) = [int(x) for x in input().split()]
ans = 0
for i in range(A, B + 1):
	s = str(i)
	S = list(s)
	if S[0] == S[4] and S[1] == S[3]:
		ans += 1
print(ans)


ans = 0
(A, B) = map(int, input().split())
for i in range(A, B + 1):
	k = str(i)
	if k[0] == k[4] and k[1] == k[3]:
		ans += 1
print(ans)


(A, B) = map(int, input().split())
count = 0
for i in range(A, B + 1):
	if str(i) == str(i)[::-1]:
		count += 1
	else:
		continue
print(count)


(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	i = list(str(i))
	t_size = len(i)
	if t_size % 2 == 0:
		if i[:t_size // 2] == list(reversed(i[t_size // 2:])):
			ans += 1
	elif i[:t_size // 2] == list(reversed(i[t_size // 2 + 1:])):
		ans += 1
print(ans)


(A, B) = list(map(int, input().split()))
num_palin = [0] * (B + 1)
for i in range(1, B + 1):
	if str(i) == str(i)[::-1]:
		num_palin[i] = num_palin[i - 1] + 1
	else:
		num_palin[i] = num_palin[i - 1]
print(num_palin[B] - num_palin[A - 1])


(A, B) = list(map(str, input().split()))
La = [int(A[:3]), int(A[3:])]
Lb = [int(B[:3]), int(B[3:])]
L = 900 - (La[0] - 100) - (999 - Lb[0])
ch1 = int(A[1] + A[0])
ch2 = int(B[1] + B[0])
if Lb[1] < ch2:
	L -= 1
if ch1 < La[1]:
	L -= 1
print(L)


(A, B) = list(map(int, input().split()))
ans = 0
for i in range(A, B + 1):
	S = str(i)
	N = len(S)
	if all((S[i] == S[-i - 1] for i in range(N // 2))):
		ans += 1
print(ans)


(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	x = str(i)
	y = x[::-1]
	if x == y:
		ans += 1
print(ans)


(A, B) = map(int, input().split())
print(sum((1 for x in range(A, B + 1) if str(x) == str(x)[::-1])))


(A, B) = map(int, input().split())
print(sum((str(n) == str(n)[::-1] for n in range(A, B + 1))))


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(a, b) = Input()
	ans = 0
	for i in range(a, b + 1):
		str_i = list(str(i))
		if str_i[0] == str_i[-1] and str_i[1] == str_i[-2]:
			ans += 1
	print(ans)
main()


(A, B) = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
	jun = str(i)
	if jun == jun[::-1]:
		cnt += 1
print(cnt)


(a, b) = map(int, input().split())
print(len([x for x in range(a, b + 1) if str(x)[:2] == str(x)[4:2:-1]]))


(a, b) = map(int, input().split())
print(len([j for j in [str(i) for i in range(a, b + 1)] if j[0] == j[4] and j[1] == j[3]]))


(a, b) = (int(i) for i in input().split())
ans = 0
for i in range(a, b + 1):
	str_i = str(i)
	if str_i[0] == str_i[-1] and str_i[1] == str_i[-2]:
		ans += 1
print(ans)


(A, B) = map(int, input().split())
ans = 0
for i in range(1, 10):
	for j in range(10):
		for k in range(10):
			if A <= i * 10000 + j * 1000 + k * 100 + j * 10 + i <= B:
				ans += 1
print(ans)


(A, B) = map(int, input().split())
Numbers = []
for i in range(A, B + 1):
	number = str(A)
	if number[0] == number[4] and number[1] == number[3]:
		Numbers.append(number)
	A += 1
print(len(Numbers))


(a, b) = list(map(int, input().split()))
ans = 0
for i in range(a, b + 1):
	key = str(i)
	if key[:2] == key[4] + key[3]:
		ans += 1
print(ans)


(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	s = str(i)
	if s[:2] == s[3:][::-1]:
		ans += 1
print(ans)


(A, B) = map(int, input().split())
ans = 0
for n in range(A, B + 1):
	s = str(n)
	ans += s == s[::-1]
print(ans)


(A, B) = [int(i) for i in input().split()]
c = 0
for n in range(A, B + 1):
	c += str(n) == str(n)[::-1]
print(c)


(a, b) = input().split()
a = int(a)
b = int(b)
c = 0
for i in range(a, b + 1):
	if i // 10000 == i - i // 10 * 10 and i // 1000 - i // 10000 * 10 == i // 10 - i // 100 * 10:
		c = c + 1
print(c)


(e1, e2) = map(str, input().split())
c = []
count = 0
ans = 0
for i in range(int(e1), int(e2) + 1):
	count = 0
	for k in range(len(str(i)) // 2):
		if str(i)[k] == str(i)[-(k + 1)]:
			count += 1
			if len(str(i)) // 2 == count:
				ans += 1
print(ans)


(k, n) = map(int, input().split())
r = 0
for i in range(k, n + 1):
	s = str(i)
	if s == s[::-1]:
		r += 1
print(r)


N = {}
cnt = 0
for i in range(10000, 100000):
	L = list(str(i))
	if L == list(reversed(L)):
		cnt += 1
	N[i] = cnt
(A, B) = map(int, input().split())
print(N[B] - N[A - 1] if A > 10000 else N[B])


(a, b) = list(map(int, input().split()))
cnt = 0
for i in range(a, b + 1):
	if str(i) == str(i)[::-1]:
		cnt += 1
print(cnt)


(A, B) = map(int, input().split())
s = 0
while A <= B:
	if str(A) == str(A)[::-1]:
		s += 1
	A += 1
print(s)


(A, B) = map(int, input().split())
c = 0
for n in range(A, B + 1):
	if str(n) == str(n)[::-1]:
		c += 1
print(c)


(A, B) = map(int, input().split())
S = 0
for I in range(A, B + 1):
	Q = str(I)
	R = Q[::-1]
	if R == Q:
		S += 1
print(S)


(n, k) = map(int, input().split())
ans = chk = 0
for i in range(n, k + 1):
	t = str(i)
	ans += t == t[::-1]
print(ans)


(a, b) = map(int, input().split())
cnt = 0
for num in range(a, b + 1):
	moji = str(num)
	if moji == moji[::-1]:
		cnt += 1
print(cnt)


(a, b) = map(int, input().split())
r = 0
for i in range(a, b + 1):
	r += str(i) == str(i)[::-1]
print(r)


(A, B) = map(int, input().split())
ans = 0
for i in range(A, B + 1):
	a = str(i)
	b = a[::-1]
	if a == b:
		ans += 1
print(ans)


(A, B) = map(int, input().split())
ans_cou = 0
for i in range(A, B + 1):
	str_i = str(i)
	reverse_str_i = ''.join(list(reversed(str_i)))
	reverse_int_i = int(reverse_str_i)
	if i == reverse_int_i:
		ans_cou += 1
print(ans_cou)


(a, b) = list(map(int, input().split()))
cnt = 0
for i in range(a, b + 1):
	lis_i = list(str(i))
	lis_i.reverse()
	rev_i = int(''.join(lis_i))
	if rev_i == i:
		cnt += 1
print(cnt)


(a, b) = input().split()
count = 0
for i in range(int(a), int(b) + 1):
	mylist = list(str(i))
	if mylist[0] == mylist[4] and mylist[1] == mylist[3]:
		count += 1
print(count)


def answer(a: int, b: int) -> int:
	count = 0
	for i in range(a, b + 1):
		i_str = str(i)
		if i_str[0] == i_str[-1] and i_str[1] == i_str[-2]:
			count += 1
	return count

def main():
	(a, b) = list(map(int, input().split()))
	print(answer(a, b))

def __starting_point():
	main()
__starting_point()


(f, t) = [int(i) for i in input().split()]
print(len([i for i in range(f, t + 1) if str(i) == str(i)[::-1]]))


(A, B) = map(int, input().split())

def ans090(A: int, B: int):
	count = 0
	for i in range(A, B + 1):
		if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2]:
			count += 1
	return count
print(ans090(A, B))


(A, B) = map(str, input().split())
l = list(range(int(A), int(B) + 1))
c = 0
for i in l:
	t = str(i)
	if t[0] == t[4] and t[1] == t[3]:
		c += 1
print(c)


from math import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import heapq
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
(a, b) = readInts()
ans = 0
for num in range(a, b + 1):
	s = str(num)
	if s == s[::-1]:
		ans += 1
print(ans)


import sys
input = sys.stdin.readline

def main():
	numbers = []
	(a, b) = map(int, input().split())
	numbers = list(range(a, b + 1))
	count = 0
	for number in numbers:
		if str(number)[0] == str(number)[-1] and str(number)[1] == str(number)[3]:
			count += 1
	print(count)

def __starting_point():
	main()
__starting_point()


(a, b) = list(map(int, input().split()))
res = 0
for i in range(a, b + 1):
	str_i = str(i)
	if str_i[0] == str_i[-1] and str_i[1] == str_i[-2]:
		res += 1
print(res)


(A, B) = list(map(int, input().split()))
a = 0
for i in range(A, B + 1):
	if str(i) == str(i)[::-1]:
		a += 1
print(a)


(a, b) = input().split()
count = 0
for i in range(int(a), int(b) + 1):
	if str(i) == str(i)[::-1]:
		count += 1
print(count)


(a, b) = map(int, input().split())
cnt = 0
for i in range(1, 10):
	for j in range(0, 10):
		for k in range(0, 10):
			num = int(str(i) + str(j) + str(k) + str(j) + str(i))
			if a <= num <= b:
				cnt += 1
print(cnt)


(a, b) = map(int, input().split())
result = 0
for x in range(a, b + 1):
	if str(x) == ''.join(reversed(str(x))):
		result += 1
print(result)


(A, B) = list(map(int, input().split()))
cnt = 0
for num in range(A, B + 1):
	num = list(str(num))
	for i in range(len(num) // 2):
		if num[i] != num[len(num) - i - 1]:
			break
	else:
		cnt += 1
print(cnt)


(A, B) = map(int, input().split())
s = 0
for i in range(A, B + 1, 1):
	n = str(i)
	m = n[::-1]
	if n == m:
		s += 1
print(s)


(a, b) = map(int, input().split())
print([str(n) == str(n)[::-1] for n in range(a, b + 1)].count(True))


def check(s):
	return s == s[::-1]
(a, b) = map(int, input().split())
print(sum((check(str(v)) for v in range(a, b + 1))))


(A, B) = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
	i = str(i)
	x = len(i) // 2
	left = i[0:x]
	right = i[x + 1:]
	reverse_right = right[::-1]
	if left == reverse_right:
		cnt += 1
print(cnt)


(x, y) = map(int, input().split())
count = 0
for i in range(x, y + 1):
	if str(i) == str(i)[::-1]:
		count += 1
print(count)


[print(sum((str(num)[0:2] == str(num)[5:2:-1] for num in range(a, b + 1)))) for (a, b) in [map(int, input().split())]]


def isPal(s):
	s = str(s)
	n = len(s)
	f = 1
	for i in range(n // 2):
		f &= s[i] == s[n - i - 1]
	return f
(a, b) = list(map(int, input().split()))
ans = 0
for i in range(a, b + 1):
	if isPal(i):
		ans += 1
print(ans)


(A, B) = map(int, input().split())
ans = 0
for _ in range(A, B + 1):
	if str(_) == str(_)[::-1]:
		ans += 1
print(ans)


ab = list(map(int, input().split()))
(a, b) = (ab[0], ab[1])
count = 0
for num in range(a, b + 1):
	str_num = str(num)
	str_num_reversed = ''.join(list(reversed(str_num)))
	if str_num == str_num_reversed:
		count += 1
print(count)


(A, B) = map(int, input().split())
ct = 0
for i in range(A, B + 1):
	s = str(i)
	if s == s[::-1]:
		ct += 1
print(ct)


(A, B) = map(int, input().split())
print([True for i in range(A, B + 1) if str(i) == str(i)[::-1]].count(True))


(a, b) = [int(x) for x in input().split()]
print(sum([1 for i in range(a, b + 1) if i == int(str(i)[::-1])]))


(A, B) = map(int, input().split())
count = 0
for i in range(A, B + 1):
	check = 0
	str_i = str(i)
	for j in range(0, len(str_i) // 2 + 1):
		if int(str_i[j]) != int(str_i[-1 - j]):
			check += 1
	if check == 0:
		count += 1
print('{}'.format(count))


(A, B) = map(int, input().split())
i = A
ans = 0
while i <= B:
	ans += 1 * (i == int(str(i)[::-1]))
	i += 1
print(ans)


(a, b) = map(int, input().split())
s = 0
for C in range(a, b + 1):
	C = str(C)
	c = C[::-1]
	s += C == c
print(s)


import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
A = l[0]
B = l[1]
cnt = 0
for i in range(A, B + 1):
	if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
		cnt += 1
print(cnt)


(A, B) = list(map(int, input().split()))

def ans090(A: int, B: int):
	ans_count = 0
	for i in range(A, B + 1):
		if str(i) == str(i)[::-1]:
			ans_count += 1
	return ans_count
print(ans090(A, B))


(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	num = 0
	j = i
	while j > 0:
		r = j % 10
		j //= 10
		num = num * 10 + r
	if i == num:
		ans += 1
print(ans)


(a, b) = input().split()
cnt = 0
for n in range(int(a), int(b) + 1):
	if str(n) == str(n)[::-1]:
		cnt += 1
print(cnt)


lst = input().split()
count = 0

def judge(n):
	if str(n) == str(n)[::-1]:
		return True
	else:
		return False
for i in range(int(lst[0]), int(lst[1]) + 1):
	if judge(i):
		count += 1
print(count)


(a, z) = map(int, input().split())
ans = 0
for i in range(a, z + 1):
	if str(i) == str(i)[::-1]:
		ans += 1
print(ans)


(a, b) = map(int, input().split())
answer = 0
for k in range(a, b + 1):
	kk = str(k)
	if kk == kk[::-1]:
		answer += 1
print(answer)


(A, B) = map(int, input().split())
ans = 0
for i in range(A, B + 1):
	S = list(str(i))
	if S == S[::-1]:
		ans += 1
print(ans)


def kaibun(n):
	if str(n)[0] == str(n)[-1] and str(n)[1] == str(n)[-2]:
		return True
	else:
		return False
(a, b) = map(int, input().split())
ans = 0
for i in range(a, b + 1):
	if kaibun(i):
		ans += 1
print(ans)


(n, m) = map(int, input().split())
a = 0
for i in range(n, m + 1):
	ii = str(i)
	if ii == ii[::-1]:
		a += 1
print(a)


(A, B) = map(int, input().split())
x = 0
for i in range(A, B + 1):
	if str(i)[0:2] == str(i)[::-1][0:2]:
		x += 1
print(x)


(a, b) = list(map(int, input().split()))
c = ''
d = ''
ans = 0
for i in range(a, b + 1):
	c = str(i)
	d = c[::-1]
	if c == d:
		ans += 1
print(ans)


(a, b) = list(map(int, input().split()))
cnt = 0
l = []
newl = []
for i in range(a, b + 1):
	l = []
	while i > 0:
		l.append(i % 10)
		i //= 10
	newl = l[::-1]
	if l == newl:
		cnt += 1
print(cnt)


(A, B) = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
	S = str(i)
	if S[0] == S[4] and S[1] == S[3]:
		cnt += 1
print(cnt)


(a, b) = map(int, input().split())
res = 0
for n in range(a, b + 1):
	s = str(n)
	if s == s[::-1]:
		res += 1
print(res)


(a, s) = map(int, input().split())
ad = 0
for i in range(a, s + 1):
	if str(i) == str(i)[::-1]:
		ad += 1
print(ad)


(A, B) = map(int, input().split())
result = 0
for i in range(A, B + 1):
	i = str(i)
	for j in range(int((len(i) - 1) / 2) + 1):
		if not i[j] == i[-j - 1]:
			break
	else:
		result += 1
print(result)


(a, b) = input().split()
f = lambda x: int(x[:3] + x[1] + x[0])
print(int(b[:3]) - int(a[:3]) + 1 - (f(a) < int(a)) - (f(b) > int(b)))


(n, m) = map(int, input().split())
ans = 0
for i in range(n, m + 1):
	if str(i) == str(i)[::-1]:
		ans += 1
print(ans)


print(sum((s[0] == s[4] and s[1] == s[3] for s in map(str, range(*map(sum, enumerate(map(int, input().split()))))))))


def judege_palindromic(val_str):
	length = len(val_str)
	match = True
	for i in range(length // 2):
		if val_str[i] != val_str[length - i - 1]:
			match = False
			break
	return match
(A, B) = map(int, input().split())
cnt = 0
for i in range(A, B + 1, 1):
	if judege_palindromic(str(i)):
		cnt += 1
print(cnt)


def reverse(num):
	test_num = 0
	while num > 0:
		remainder = num % 10
		test_num = test_num * 10 + remainder
		num = num // 10
	return test_num
(a, b) = list(map(int, input().split()))
c = 0
for i in range(a, b + 1):
	if i == reverse(i):
		c += 1
print(c)


(a, b) = map(int, input().split())
print(len([1 for i in range(a, b + 1) if i // 1000 == i % 10 * 10 + i % 100 // 10]))


(A, B) = [int(x) for x in input().split()]
res = 0
for i in range(A, B + 1):
	if str(i) == str(i)[::-1]:
		res += 1
print(res)


(a, b) = map(int, input().split())
print(len([i for i in range(a, b + 1) if str(i) == ''.join(list(reversed(str(i))))]))


(a, b) = list(map(int, input().split()))
cnt = 0
for i in range(a, b + 1):
	l = []
	while i > 0:
		l.append(i % 10)
		i //= 10
	if l[0] == l[4] and l[1] == l[3]:
		cnt += 1
print(cnt)


(a, b) = [int(x) for x in input().split()]

def check(p):
	p = str(p)
	if p[0] == p[4] and p[1] == p[3]:
		return True
	return False
res = 0
for i in range(a, b + 1):
	if check(i):
		res += 1
print(res)


(a, b) = map(int, input().split())
count = 0
for i in range(a, b + 1):
	s = str(i)
	if s[0] == s[4] and s[1] == s[3]:
		count += 1
print(count)


(A, B) = map(int, input().split())
ans = 0
for i in range(A, B + 1):
	for j in range(len(str(i))):
		zen = j
		kou = len(str(i)) - 1 - j
		if zen >= kou:
			ans += 1
			break
		if str(i)[zen] != str(i)[kou]:
			break
print(ans)


(A, B) = map(int, input().split())
c = 0
for i in range(A, B + 1):
	t = str(i)
	if t == t[::-1]:
		c += 1
print(c)


(l, h) = map(int, input().split())
print(sum((1 if str(x) == str(x)[::-1] else 0 for x in range(l, h + 1))))


(A, B) = map(int, input().split())
n = 0
for i in range(A, B + 1):
	C = str(i)[-1::-1]
	if int(C) == i:
		n = n + 1
print(n)


(a, b) = map(int, input().split())
ans = []
for i in range(a, b + 1):
	c = [j for j in str(i)]
	if c[0] == c[-1] and c[1] == c[-2]:
		ans.append(i)
print(len(ans))