The Little Elephant very much loves sums on intervals.

This time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x equals the last one (in decimal notation). For example, such numbers as 101, 477474 or 9 will be included in the answer and 47, 253 or 1020 will not.

Help him and count the number of described numbers x for a given pair l and r.

Input

The single line contains a pair of integers l and r (1 ≤ l ≤ r ≤ 1018) — the boundaries of the interval.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

Output

On a single line print a single integer — the answer to the problem.

Examples

Input

2 47


Output

12


Input

47 1024


Output

98

Note

In the first sample the answer includes integers 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44.

Source: codeforces | Difficulty: MEDIUM
Tags: Dynamic programming

Sorting

Combinatorics


Solutions:
def F(x):
	if x < 10:
		return x
	rv = 9
	tmp = x
	len = 0
	while tmp > 0:
		len += 1
		tmp = tmp // 10
	d = int(x // pow(10, len - 1))
	tmp = 1
	for i in range(len - 2):
		rv += 9 * tmp
		tmp *= 10
	for i in range(1, 10):
		if i < d:
			rv += 1 * tmp
	if x // pow(10, len - 1) <= x % 10:
		rv += 1
	rv += x % pow(10, len - 1) // 10
	return rv
(l, r) = map(int, input().split())
print(abs(F(r) - F(l - 1)))


(l, r) = map(int, input().split())

def f(n):
	cnt = 0
	m = len(str(n))
	for i in range(1, 10):
		for j in range(0, 18):
			x = i * 10 ** (j + 1) + i
			if len(str(x)) < m:
				cnt += 10 ** j
			elif len(str(x)) == m:
				if i < int(str(n)[0]):
					cnt += 10 ** j
				elif i == int(str(n)[0]):
					z = str(n)[1:m - 1]
					zz = 0
					if z != '':
						zz = int(z)
					if int(str(n)[-1]) >= i:
						cnt += zz + 1
					elif int(str(n)[-1]) < i:
						cnt += zz
	cnt += min(9, n)
	return cnt
print(f(r) - f(l - 1))


def count(x):
	if x < 10:
		res = x
	else:
		f = x % 10
		d = x // 10
		co = 1
		res = 9
		while x > 99:
			res += 9 * co
			co *= 10
			x //= 10
		x //= 10
		res += d - co
		if f >= x:
			res += 1
	return res
(l, r) = map(int, input().split())
print(count(r) - count(l - 1))


def f(x):
	return x if x < 10 else x // 10 + 9 - (0 if str(x)[0] <= str(x)[-1] else 1)
(l, r) = map(int, input().split())
print(f(r) - f(l - 1))


def fin(n):
	aa = str(n)
	ans = 0
	if len(aa) > 1:
		ans = 9
	for i in range(2, len(aa)):
		ans += 9 * 10 ** (i - 2)
	if aa[-1] < aa[0]:
		ans += int('0' + aa[1:-1])
	else:
		ans += int('0' + aa[1:-1]) + 1
	ans += (int(aa[0]) - 1) * 10 ** len(aa[1:-1])
	return ans
(l, r) = map(int, input().split())
print(fin(r) - fin(l - 1))


(l, r) = list(map(int, input().split()))

def cnt(x):
	ret = 0
	for i in range(1, x + 1):
		s = str(i)
		if s[0] == s[-1]:
			ret += 1
	return ret

def cnt2(x):
	ret = 0
	s = str(x)
	L = len(s)
	if L >= 2 and x == 10 ** (L - 1):
		return cnt2(10 ** (L - 1) - 1)
	if L <= 1:
		return x
	elif L <= 2:
		while x // 10 != x % 10:
			x -= 1
		return 9 + x // 10
	else:
		ret = int('1' + '0' * (L - 3) + '8')
		num = list(str(x))
		if num[0] != num[-1]:
			if int(num[0]) > int(num[-1]):
				how = int(num[-1]) + 10 - int(num[0])
			else:
				how = int(num[-1]) - int(num[0])
			x -= how
		num = str(x)
		d = x % 10
		ret += int(d - 1) * int('9' * (L - 2)) + int(num[1:-1]) + int(d)
	return ret
print(cnt2(r) - cnt2(l - 1))


def modinv(n, p):
	return pow(n, p - 2, p)

def get_numbers(s):
	if len(s) == 1:
		return int(s)
	ans = 0
	n = len(s)
	for i in range(1, n):
		ans += 9 * 10 ** max(0, i - 2)
	x = n - 2
	for i in range(n):
		k = int(s[i])
		if i == 0:
			k -= 1
		ans += k * 10 ** x
		x -= 1
		if x < 0:
			break
	if int(s[-1]) >= int(s[0]):
		ans += 1
	return ans

def main():
	(l, r) = [int(x) for x in input().split()]
	print(get_numbers(str(r)) - get_numbers(str(l - 1)))
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


dp = [0] * 22
dp[1] = 9
dp[2] = 9
dp[3] = 90
for i in range(4, 21):
	dp[i] = dp[i - 1] * 10
for i in range(1, 21):
	dp[i] = dp[i] + dp[i - 1]

def good(s):
	if str(s)[0] == str(s)[-1]:
		return 1
	return 0

def till(x):
	Ans = 0
	N = len(str(x))
	if N == 1:
		return int(x)
	Ans += dp[N - 1]
	x = str(x)
	Ans += (int(x[0]) - 1) * 10 ** (N - 2)
	for i in range(1, N - 1):
		Ans += int(x[i]) * 10 ** (N - i - 2)
	if int(x[-1]) >= int(x[0]):
		Ans += 1
	return Ans
(l, r) = map(int, input().split())
Ans = 0
if r <= 100:
	for i in range(l, r + 1):
		Ans += good(i)
	print(Ans)
else:
	print(int(till(r) - till(l) + good(l)))


def count(l, L):
	x = 0
	if L <= 9:
		x = L
	else:
		x += 9
		if L <= 100:
			x += L // 11
		else:
			x += 9
			leng = len(l)
			for i in range(max(0, leng - 3)):
				x += 9 * 10 ** (i + 1)
			leng -= 2
			for (i, y) in enumerate(l[:-1]):
				y = int(y)
				if i == 0:
					y -= 1
				if y > 0:
					x += y * 10 ** leng
				leng -= 1
			if int(l[-1]) >= int(l[0]):
				x += 1
	return x
(l1, l2) = map(str, input().split())
a = count(l1, int(l1))
b = count(l2, int(l2))
if int(l1[0]) == int(l1[-1]):
	a -= 1
print(b - a)


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def calc(x):
	return x if x < 10 else x // 10 + 9 - (0 if str(x)[0] <= str(x)[-1] else 1)

def solve():
	(l, r) = read()
	print(calc(r) - calc(l - 1))
for _ in range(1):
	solve()


import sys

def fix(a):
	while a[0] != a[-1]:
		a = str(int(a) - 1)
	return a

def lowerOrEqual(x):
	x = fix(x)
	if int(x) <= 999:
		good = 0
		while int(x) > 0:
			if x[0] == x[-1]:
				good += 1
			x = str(int(x) - 1)
		return good
	mid = int(x[1:len(x) - 1])
	x = str(int(x) - mid * 10 - 1)
	return mid + 1 + lowerOrEqual(x)
line = sys.stdin.readline().split(' ')
(a, b) = (str(int(line[0]) - 1), str(int(line[1])))
print(lowerOrEqual(b) - lowerOrEqual(a))


from math import log, floor
rdi = lambda : list(map(int, input().split()))

def f(x):
	if x < 10:
		return x
	ans = 9
	n = int(log(x, 10)) + 1
	for i in range(2, n):
		ans += 9 * 10 ** (i - 2)
	head = x // 10 ** (n - 1)
	tail = x % 10
	ans += (head - 1) * 10 ** (n - 2)
	ans += (x - head * 10 ** (n - 1) - tail) // 10 + (tail >= head)
	return ans
(l, r) = rdi()
print(f(r) - f(l - 1))


(l, r) = map(int, input().split())
(ans, t) = (0, dict({l - 1: 0, r: 0}))
if l == r:
	exit(print(1 if str(l)[0] == str(l)[-1] else 0))
for num in [l - 1, r]:
	le = 1
	while True:
		if len(str(num)) > le:
			if le < 3:
				t[num] += 9
			else:
				t[num] += 10 ** (le - 2) * 9
		else:
			if le == 1:
				t[num] += num
			elif le == 2:
				t[num] += int(str(num)[0]) if str(num)[1] >= str(num)[0] else int(str(num)[0]) - 1
			else:
				t[num] += int(str(num)[1:-1]) if int(str(num)[-1]) < int(str(num)[0]) else int(str(num)[1:-1]) + 1
				t[num] += (int(str(num)[0]) - 1) * 10 ** (le - 2)
			break
		le += 1
print(t[r] - t[l - 1])


def cal(s):
	n = len(s)
	if int(s) <= 9:
		return int(s)
	ans = 9
	for j in range(2, n):
		ans += 9 * pow(10, j - 2)
	d = int(s[0])
	ans += (d - 1) * pow(10, n - 2)
	if n > 2:
		ans += int(s[1:n - 1])
	if int(s[-1]) >= int(s[0]):
		ans += 1
	return ans
(a, b) = input().split(' ')
print(cal(b) - cal(str(int(a) - 1)))


(l, r) = input().split()

def count(s: str) -> int:
	if s[0] != s[-1]:
		while s[0] != s[-1]:
			s = str(int(s) - 1)
	length = len(s)
	if length == 1:
		return int(s)
	if length == 2:
		return 9 + int(s[0])
	cnt = 9 + 9
	cnt += 1 + int(s[1:-1])
	cnt += (int(s[0]) - 1) * 10 ** (length - 2)
	cnt += sum((9 * 10 ** (n - 2) for n in range(3, length)))
	return cnt
print((l[0] != l[-1]) * -1 + count(r) - count(l) + 1)


(left, right) = map(int, input().split())

def f(x):
	if x < 10:
		return x
	a = []
	t = x
	while t:
		a.append(t % 10)
		t //= 10
	a = a[::-1]
	ret = min(9, x)
	size = len(a)
	first = a[0]
	last = a[-1]
	for curSize in range(size - 1):
		for dig in range(1, 10):
			if curSize < size - 2 or dig < first:
				ret += 10 ** curSize
			elif dig == first:
				s = 0
				for i in range(1, size - 1):
					s = s * 10 + a[i]
				ret += s
				if last >= dig:
					ret += 1
	return ret
print(f(right) - f(left - 1))


def pre(n):
	if n == 0:
		return 0
	if n < 10:
		return n
	if n < 100:
		return 9 + n // 11
	digit = []
	while n:
		digit += [n % 10]
		n //= 10
	ans = 10 ** (len(digit) - 2) - 1
	digit.reverse()
	ans += int(''.join(map(str, digit[1:-1])))
	ans += digit[0] <= digit[-1]
	ans += 10 ** (len(digit) - 2) * (digit[0] - 1)
	return ans + 9
(l, r) = map(int, input().split())
print(pre(r) - pre(l - 1))


(l, r) = map(int, input().split())
l = l - 1
lc = 0
rc = 0
while len(str(l)) > 3:
	s = str(l)
	while s[0] != s[-1]:
		l = l - 1
		s = str(l)
	lc = lc + int(s[1:-1]) + 1
	l = l - int(s[1:])
	l = l - 1
while l != 0:
	s = str(l)
	if s[0] == s[-1]:
		lc = lc + 1
		l = l - 1
	else:
		l = l - 1
while len(str(r)) > 3:
	s = str(r)
	while s[0] != s[-1]:
		r = r - 1
		s = str(r)
	rc = rc + int(s[1:-1]) + 1
	r = r - int(s[1:])
	l = r - 1
while r != 0:
	s = str(r)
	if s[0] == s[-1]:
		rc = rc + 1
		r = r - 1
	else:
		r = r - 1
print(rc - lc)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
length_wise = [0, 10, 19]
for i in range(3, 19):
	length_wise.append(9 * 10 ** (i - 2) + length_wise[-1])

def operate(x):
	if x == -1:
		return 0
	x = str(x)
	if len(x) == 1:
		return int(x) + 1
	ans = length_wise[len(x) - 1]
	key = min(int(x[0]), int(x[-1]))
	key1 = max(int(x[0]), int(x[-1]))
	if key == int(x[0]):
		type = 1
	else:
		type = 2
	x = x[1:-1]
	ans1 = 0
	try:
		ans1 = int(x)
	except:
		pass
	if type == 2:
		ans += (key1 - 1) * 10 ** len(x)
	else:
		ans += (key - 1) * 10 ** len(x)
		ans1 += 1
	return ans + ans1
(l, r) = value()
print(operate(r) - operate(l - 1))


def size(x):
	res = 0
	while x > 0:
		x //= 10
		res += 1
	return res

def first(x):
	last = 0
	while x > 0:
		last = x % 10
		x //= 10
	return last

def last(x):
	return x % 10

def cut(x):
	x //= 10
	x -= first(x) * 10 ** (size(x) - 1)
	return x

def part(x):
	if x < 10:
		return x
	res = 9
	for i in range(2, size(x)):
		res += 9 * 10 ** (i - 2)
	res += cut(x)
	res += (first(x) - 1) * 10 ** (size(x) - 2)
	if first(x) <= last(x):
		res += 1
	return res
(l, r) = list(map(int, input().split()))
print(part(r) - part(l - 1))


def func(b):
	n2 = len(b)
	ans = 0
	for i in range(1, n2):
		if i == 1:
			ans += 9
		else:
			ans += 9 * 10 ** (i - 2)
	for i in range(0, n2 - 1):
		if n2 > 2:
			if i == 0:
				tmp = (int(b[i]) - 1) * 10 ** (n2 - 2 - i)
			else:
				tmp = int(b[i]) * 10 ** (n2 - 2 - i)
		else:
			tmp = int(b[i]) - 1
		ans += tmp
	if n2 == 1:
		ans = int(b)
	elif int(b[n2 - 1]) >= int(b[0]):
		ans -= -1
	return ans
(a, b) = map(int, input().split())
a += -1
a = str(a)
b = str(b)
ans1 = func(a)
ans2 = func(b)
print(func(b) - func(a))


(l, r) = list(map(int, input().split()))
a = len(str(l))
b = len(str(r))
ans = 0
if a == b:
	if l == r:
		if str(l)[0] == str(l)[-1]:
			print(1)
		else:
			print(0)
	elif a == 1:
		ans += r - l + 1
		print(ans)
	else:
		temp1 = str(l)[:a - 1]
		temp2 = str(r)[:b - 1]
		ans += int(temp2) - int(temp1)
		if int(str(l)[-1]) <= int(str(l)[0]):
			ans += 1
		if int(str(r)[-1]) < int(str(r)[0]):
			ans -= 1
		print(ans)
else:
	for i in range(a + 1, b):
		ans += 9 * 10 ** (i - 2)
	if a > 1:
		temp1 = str(l)[:a - 1]
		temp2 = '9' * len(temp1)
		ans += int(temp2) - int(temp1)
		if int(str(l)[-1]) <= int(str(l)[0]):
			ans += 1
		temp3 = str(r)[:b - 1]
		temp4 = '1' + '0' * (len(temp3) - 1)
		ans += int(temp3) - int(temp4)
		if int(str(r)[-1]) >= int(str(r)[0]):
			ans += 1
		print(ans)
	else:
		ans += 9 - l + 1
		temp3 = str(r)[:b - 1]
		temp4 = '1' + '0' * (len(temp3) - 1)
		ans += int(temp3) - int(temp4)
		if int(str(r)[-1]) >= int(str(r)[0]):
			ans += 1
		print(ans)


def f(n):
	mx = len(str(n))
	ans = 0
	for i in range(1, mx):
		for j in range(1, 10):
			if i == 1:
				ans += 1
			else:
				ans += 10 ** (i - 2)
	for j in range(1, 10):
		if mx == 1:
			if j <= n:
				ans += 1
			else:
				break
			continue
		if int(str(j) + '0' * (mx - 2) + str(j)) > n:
			break
		if int(str(j) + '9' * (mx - 2) + str(j)) <= n:
			ans += 10 ** (mx - 2)
		else:
			val = int(str(n)[1:-1]) + 1
			if str(n)[-1] < str(n)[0]:
				val -= 1
			ans += val
			break
	return ans
(L, R) = map(int, input().split())
print(f(R) - f(L - 1))


def find(s):
	n = len(s)
	x = int(s)
	if x < 10:
		return x
	ans = x // 10 - 1
	ans += 9
	if s[0] <= s[n - 1]:
		ans += 1
	return ans
(l, r) = map(int, input().split())
l = l - 1
l = str(l)
r = str(r)
count1 = find(l)
count2 = find(r)
print(count2 - count1)


import sys

def lowerOrEqual(x):
	if int(x) <= 999:
		good = 0
		while int(x) > 0:
			if x[0] == x[-1]:
				good += 1
			x = str(int(x) - 1)
		return good
	if x[0] == '1':
		mid = int(x[1:len(x) - 1])
		new = ''.join('9' * (len(x) - 1))
		return mid + 1 + lowerOrEqual(new)
	else:
		end = str(int(x[0]) - 1)
		mid = int(x[1:len(x) - 1])
		new = end + ''.join('9' * (len(x) - 2)) + end
		return mid + 1 + lowerOrEqual(new)

def fix(a):
	while a[0] != a[-1]:
		a = str(int(a) - 1)
	return a
line = sys.stdin.readline().split(' ')
(a, b) = (str(int(line[0]) - 1), str(int(line[1])))
(a, b) = (fix(a), fix(b))
print(lowerOrEqual(b) - lowerOrEqual(a))


n = input().split()
l = int(n[0])
r = int(n[1])
s = 0
if l == 235 and r == 236:
	print(0)
	exit()
if r == l and str(r)[0] == str(r)[len(str(r)) - 1]:
	print(1)
	exit()
if r == l:
	print(0)
	exit()
if r <= 100:
	for i in range(l, r + 1):
		i = str(i)
		if i[0] == i[len(i) - 1]:
			s += 1
	print(s)
	exit()
if l >= 100:
	s1 = (l - 100) // 10
	s2 = (r - 100) // 10
	r2 = str(r)
	l2 = str(l)
	if r2[0] <= r2[len(r2) - 1]:
		print(s2 - s1 + 1)
		exit()
	elif l2[0] < l2[len(l2) - 1]:
		print(s2 - s1 - 1)
		exit()
	print(s2 - s1)
if r > 100 and l < 100:
	for i in range(l, 100):
		i = str(i)
		if i[0] == i[len(i) - 1]:
			s += 1
	if str(r)[0] < str(r)[len(str(r)) - 1]:
		print(s + (r - 100) // 10 + 1)
		exit()
	print(s + (r - 100) // 10)


def get_digit(n):
	return len(str(n))

def get_last(n):
	return n % 10

def get_first(n):
	m = str(n)
	return int(m[0])

def get_mid(n):
	if n < 100:
		return 0
	m = str(n)
	return int(m[1:len(m) - 1])

def f(n):
	if n < 10:
		return n
	d = get_digit(n)
	la = get_last(n)
	fi = get_first(n)
	m = get_mid(n)
	ans = 0
	for i in range(0, d - 1):
		for j in range(1, 10):
			if i < d - 2:
				ans += 10 ** i
			elif j < fi:
				ans += 10 ** i
			elif j == fi:
				ans += m
				if j <= la:
					ans += 1
	return ans + 9

def main():
	(l, r) = list(map(int, input().split()))
	print(f(r) - f(l - 1))
main()


(l, r) = map(int, input().split())

def upto_x(n):
	if n < 10:
		return n
	sm = n // 10 + 9
	if str(n)[-1] < str(n)[0]:
		sm -= 1
	return sm
print(upto_x(r) - upto_x(l - 1))


import os
import sys
from io import BytesIO, IOBase

def solve(x):
	a = [10, 9]
	x = str(x)
	for i in range(3, len(x)):
		a.append(pow(10, i - 2) * 9)
	return sum(a[:len(x) - 1]) + (int(x[0]) - (len(x) != 1)) * pow(10, max(len(x) - 2, 0)) + (int(x[1:len(x) - 1]) if len(x) > 2 else 0) + (x[-1] >= x[0])

def main():
	(l, r) = map(int, input().split())
	print(solve(r) - solve(l - 1))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import *
allen = None

def modulus(x):
	return x if x > 0 else 0

def compute(x, lenx):
	if lenx == 1:
		return x
	num = 0
	num += allen[lenx - 1]
	strx = str(x)
	firstdigchar = strx[0]
	firstdig = int(firstdigchar)
	num += (firstdig - 1) * 10 ** (lenx - 2)
	newnum = int(firstdigchar + '0' * (lenx - 2) + firstdigchar)
	num += x // 10 - newnum // 10
	if x % 10 >= newnum % 10:
		num += 1
	else:
		num += 0
	return num

def main():
	global allen
	(l, r) = [int(x) for x in input().split()]
	l = l - 1
	(lenl, lenr) = (len(str(l)), len(str(r)))
	maxlen = max(lenl, lenr, 3)
	allen = [None for _ in range(maxlen + 1)]
	allen[1] = 9
	allen[2] = 9 + allen[1]
	for ilen in range(3, maxlen + 1):
		allen[ilen] = 9 * 10 ** (ilen - 2) + allen[ilen - 1]
	outl = compute(l, lenl)
	outr = compute(r, lenr)
	print(outr - outl)
main()


def find(s):
	n = len(s)
	x = 0
	for i in range(n):
		x = x * 10 + (ord(s[i]) - ord('0'))
	if x < 10:
		return x
	ans = x // 10 - 1
	ans += 9
	if s[0] <= s[n - 1]:
		ans += 1
	return ans
(l, r) = map(int, input().split())
l = l - 1
l = str(l)
r = str(r)
res1 = find(l)
res2 = find(r)
print(res2 - res1)


from collections import Counter
from math import log2

def dfs(x, y, x1, y1):
	v.add((x, y))
	for (dx, dy) in [(-1, 0), (0, 1), (1, 0), (0, -1)]:
		if x + dx >= 0 and x + dx < n and (y + dy >= 0) and (y + dy < m) and ((x + dx, y + dy) != (x1, y1)) and (a[x + dx][y + dy] == a[x][y]):
			if (x + dx, y + dy) in v or dfs(x + dx, y + dy, x, y):
				return True
	return False
import sys
sys.setrecursionlimit(10000)

def ans(x):
	if x <= 9:
		return x
	else:
		return x // 10 + 9 - (1 if str(x)[0] > str(x)[-1] else 0)
(n, m) = map(int, input().split())
print(ans(m) - ans(n - 1))


(l, r) = input().split()

def ans(n):
	a = 0
	if len(n) == 1:
		return int(n)
	elif len(n) == 2:
		if n[1] <= n[0]:
			return int(n[0]) + 9
		else:
			return int(n[0]) + 10
	else:
		for i in range(len(n) - 1):
			if i > 0:
				a += int(n[i]) * 10 ** (len(n) - i - 2)
			else:
				a += (int(n[i]) - 1) * 10 ** (len(n) - i - 2)
			if i == len(n) - 2:
				if n[-1] > n[0]:
					a += 1
		return a
x = ans(r)
y = ans(l)
if int(l) > 99:
	for i in range(len(l) - 1, 1, -1):
		y += ans('9' * i) + 1
if int(r) > 99:
	for i in range(len(r) - 1, 1, -1):
		x += ans('9' * i) + 1
if r[0] == r[-1]:
	x += 1
print(x - y)


p = [0, 1, 1]
p.extend([10 ** x for x in range(1, 19)])

def get_count(num):
	if len(num) == 1:
		return int(num)
	elif len(num) == 2:
		return int(num[0]) + 8 if num[0] > num[1] else int(num[0]) + 9
	else:
		result = 18
		for i in range(3, len(num)):
			result += p[i] * 9
		firstDig = int(num[0])
		lastDig = int(num[-1])
		result += (firstDig - 1) * 10 ** (len(num) - 2)
		if firstDig <= lastDig:
			result += int(num[1:-1]) + 1
		else:
			result += int(num[1:-1])
		return result
(a, b) = input().split()
ca = get_count(a)
cb = get_count(b)
print(cb - ca + 1 if a[0] == a[-1] else cb - ca)


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def msi():
	return map(str, input().split())

def li():
	return list(mi())

def f(n):
	m = len(str(n))
	if m == 1:
		return n
	ans = 0
	for i in range(1, m):
		ans += max(10 ** (i - 2), 1) * 9
	ans += (int(str(n)[0]) - 1) * max(10 ** (m - 2), 1)
	num = int(str(n)[1:])
	if int(str(n)[0]) <= int(str(n)[-1]):
		ans += num // 10 + 1
	else:
		ans += num // 10
	return ans
(l, r) = mi()
if str(l)[0] == str(l)[-1]:
	print(f(r) - f(l) + 1)
else:
	print(f(r) - f(l))


(l, r) = map(int, input().split())
result = 0
for digit in range(1, 10):
	d_str = str(digit)
	for length in range(3, 19):
		if int(d_str + (length - 2) * '0' + d_str) <= r and int(d_str + (length - 2) * '9' + d_str) >= l:
			(a, b, c) = (0, int((length - 2) * '9'), 0)
			while a < b:
				c = (a + b) // 2
				if int(d_str + '0' * (length - 2 - len(str(c))) + str(c) + d_str) < l:
					a = c + 1
				else:
					b = c
			l_end = a
			(a, b, c) = (0, int((length - 2) * '9'), 0)
			while a < b:
				c = (a + b + 1) // 2
				if int(d_str + '0' * (length - 2 - len(str(c))) + str(c) + d_str) > r:
					b = c - 1
				else:
					a = c
			r_end = a
			result += r_end - l_end + 1
for digit in range(1, 10):
	length = 1
	if l <= digit and digit <= r:
		result += 1
	length = 2
	if int(str(digit) + str(digit)) >= l and int(str(digit) + str(digit)) <= r:
		result += 1
print(result)


inp = input()
(a, b) = inp.split(' ')

def calc(a):
	n = len(a)
	ans = 0
	if n == 1:
		return int(a)
	if n == 2:
		ans += 8 + int(a[0])
		if int(a[1]) >= int(a[0]):
			return ans + 1
		return ans
	ans += 8 + 10 ** (n - 2)
	ans += (int(a[0]) - 1) * 10 ** (n - 2)
	for i in range(1, n - 1):
		ans += int(a[i]) * 10 ** (n - 2 - i)
	if int(a[-1]) >= int(a[0]):
		return ans + 1
	return ans
print(calc(b) - calc(str(int(a) - 1)))


def fin(r):
	if r < 10:
		return r
	ans = r // 10 + 9
	l = len(str(r))
	if r % 10 < r // 10 ** (l - 1):
		ans -= 1
	return ans
(l, r) = map(int, input().split())
print(fin(r) - fin(l - 1))


(l, r) = map(int, input().split())

def count_valid(x):
	if x < 10:
		return x
	if str(x)[0] > str(x)[-1]:
		return x // 10 + 8
	else:
		return x // 10 + 8 + 1
print(count_valid(r) - count_valid(l - 1))


def ans(num):
	return num if num < 10 else num // 10 + 9 - (0 if str(num)[0] <= str(num)[-1] else 1)
(l, r) = map(int, input().split())
print(ans(r) - ans(l - 1))


def f(x):
	s = str(x)
	return x // 10 + min(x, 9) - (s[0] > s[-1])
(n, m) = map(int, input().split())
print(f(m) - f(n - 1))


(l, r) = map(int, input().split())
ten = 1
res = 0
for i in range(18):
	for d in range(1, 10, 1):
		(low, high) = (d * ten, (d + 1) * ten - 1)
		low = max(low, l)
		high = min(high, r)
		while low % 10 != d:
			low += 1
		while high % 10 != d:
			high -= 1
		if low <= high:
			res += (high - low) // 10 + 1
	ten *= 10
print(res)


def floor(x, y):
	return x // y

def ceil(x, y):
	return x // y + (x % y != 0)
(l, r) = map(int, input().split())
ans = (l <= 9) * (min(r, 9) - l + 1)
for k in range(0, 17):
	for d in range(1, 10):
		rb = floor(r - d, 10) - 10 ** k * d
		lb = ceil(l - d, 10) - 10 ** k * d
		rx = min(10 ** k - 1, rb)
		lx = max(0, lb)
		ans += (rx >= lx) * (rx - lx + 1)
print(ans)


import math
(l, r) = map(int, input().split())

def f(x):
	x = list(map(int, x))
	a = len(x)
	if a < 2:
		return int(x[0])
	ans = 0
	for i in range(1, a):
		ans += 9 * int(math.pow(10, max(0, i - 2)))
	ans += (x[0] - 1) * int(math.pow(10, max(0, a - 2)))
	if len(x) > 2:
		z = x[1:len(x) - 1]
		ans += int(''.join(map(str, z)))
	if x[0] <= x[-1]:
		ans += 1
	return int(ans)
print(f(list(str(r))) - f(list(str(l - 1))))


def calc(r):
	if r < 10:
		return r
	(ret, l) = (r // 10 + 9, len(str(r)))
	if r % 10 < r // 10 ** (l - 1):
		ret -= 1
	return ret
(l, r) = map(int, input().split())
print(calc(r) - calc(l - 1))


(l, r) = [int(s) for s in input().split()]

def f1(x):
	c = 0
	for i in range(x + 1):
		if str(i)[0] == str(i)[-1]:
			c += 1
	return c

def f(x):
	if x < 10:
		return x + 1
	if x < 100:
		return 10 + x // 10 - (1 if x % 10 < x // 10 else 0)
	res = 19
	c = 1
	for l in range(3, len(str(x))):
		c *= 10
		res += 9 * c
	c *= 10
	res += (int(str(x)[0]) - 1) * c
	res += int(str(x)[1:-1]) + 1
	res -= 1 if int(str(x)[0]) > int(str(x)[-1]) else 0
	return res
print(f(r) - f(l - 1))


def f(x):
	l = len(str(x))
	if l == 1:
		return x
	if l == 2:
		t = 0
		for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99]:
			if i <= x:
				t += 1
		return t
	ans = 9
	for i in range(2, l):
		ans += 9 * 10 ** (i - 2)
	ans += 10 ** (l - 2) * (int(str(x)[0]) - 1)
	ans += int(str(x)[1:len(str(x)) - 1])
	if int(str(x)[-1]) < int(str(x)[0]):
		ans -= 1
	return ans + 1
(a, b) = list(map(int, input().split(' ')))
print(f(b) - f(a - 1))


def helper(x):
	s = str(x)
	return x // 10 + min(x, 9) - (s[0] > s[-1])

def main():
	(a, b) = map(int, input().split())
	print(helper(b) - helper(a - 1))
main()


(l, r) = input().split()
lr = len(r)
retr = 1
if lr > 1:
	for i in range(1, lr):
		retr += 9 * 10 ** max(i - 2, 0)
	r0 = int(r[0])
	retr += (r0 - 1) * 10 ** (lr - 2)
	hr = r0 * (10 ** (lr - 1) + 1)
	retr += (int(r) - hr) // 10 + 1
else:
	retr += int(r)
ll = len(l)
retl = 1
if ll > 1:
	for i in range(1, ll):
		retl += 9 * 10 ** max(i - 2, 0)
	l0 = int(l[0])
	retl += (l0 - 1) * 10 ** (ll - 2)
	hl = l0 * (10 ** (ll - 1) + 1)
	retl += (int(l) - hl) // 10 + 1
else:
	retl += int(l)
if l[-1] == l[0]:
	retl -= 1
print(retr - retl)


import math
import sys
from bisect import bisect_right, bisect_left
from collections import Counter, defaultdict
from heapq import heappop, heappush
from itertools import accumulate
from sys import stdout
R = lambda : map(int, input().split())
(a, b) = R()

def cnt(num):
	if num < 10:
		return num
	tmp = num
	n = 0
	t = []
	while tmp:
		t.append(tmp % 10)
		tmp //= 10
		n += 1
	res = 0
	for x in range(n - 1):
		if x == 0:
			res += 9
		else:
			res += 9 * 10 ** (x - 1)
	for i in range(1, n):
		d = t[i]
		if i < n - 1:
			res += d * 10 ** (i - 1)
		else:
			res += (d - 1) * 10 ** (i - 1)
	if t[0] >= t[-1]:
		res += 1
	return res
print(cnt(b) - cnt(a - 1))


(l, r) = map(int, input().split())

def get(n, x, mid):
	return int(str(x) + '0' * (n - len(str(mid)) - 2) + str(mid) + str(x))

def go(n, x):
	if n == 1:
		return int(l <= x <= r)
	if n == 2:
		return int(l <= 11 * x <= r)
	lo = 0
	hi = int('9' * (n - 2))
	if get(n, x, hi) < l or get(n, x, lo) > r:
		return 0
	while hi - lo > 1:
		mid = (hi + lo) // 2
		if get(n, x, mid) <= r:
			lo = mid
		else:
			hi = mid
	rgt = lo
	if rgt < hi and get(n, x, rgt + 1) <= r:
		rgt += 1
	lo = 0
	hi = int('9' * (n - 2))
	while hi - lo > 1:
		mid = (hi + lo) // 2
		if get(n, x, mid) < l:
			lo = mid
		else:
			hi = mid
	lft = lo + 1
	if lft > 0 and get(n, x, lft - 1) >= l:
		lft -= 1
	return rgt - lft + 1
ans = 0
for i in range(1, 20):
	for x in range(1, 10):
		ans += go(i, x)
print(ans)


import bisect

def cal(n):
	x = str(n)
	res = 0
	if len(x) == 1:
		return n
	for i in range(1, len(x)):
		res = res + 9 * 10 ** max(0, i - 2)
	a = []
	for i in range(1, 10):
		s = str(i) + '0' * max(0, len(x) - 2) + str(i)
		a.append(int(s))
	j = bisect.bisect_right(a, n)
	res = res + (j - 1) * 10 ** max(0, len(x) - 2)
	if j < len(a) and x[0] == str(a[j])[0]:
		res = res + 10 ** max(0, len(x) - 2)
	else:
		for i in range(1, len(x) - 1):
			res = res + int(x[i]) * 10 ** (len(x) - 2 - i)
		if len(x) >= 2:
			res = res + 1
		if int(x[0]) > int(x[-1]):
			res = res - 1
	return res
(l, r) = list(map(int, input().split()))
ans = cal(r) - cal(l)
if str(l)[0] == str(l)[-1]:
	ans = ans + 1
print(ans)


def Solve(t):
	if t < 10:
		return t
	A = 9
	for i in range(2, 20):
		if 10 ** i - 1 <= t:
			A += 9 * 10 ** (i - 2)
		else:
			fd = int(str(t)[0])
			ld = t % 10
			A += (fd - 1) * 10 ** (i - 2)
			t -= fd * 10 ** (i - 1)
			if ld >= fd:
				A += 1
			t = t // 10
			A += t
			break
	return A
(l, r) = map(int, input().split())
print(Solve(r) - Solve(l - 1))


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
M = 10 ** 9 + 7
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def prime(x):
	if x == 1:
		return False
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return False
		else:
			return True

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def factorization(n, l):
	c = n
	if prime(n) == True:
		l.append(n)
		return l
	for i in range(2, c):
		if n == 1:
			break
		while n % i == 0:
			l.append(i)
			n = n // i
	return l

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	sub = []
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] < A[i]:
				sub.append(l[k])
		l[i] = 1 + max(sub, default=0)
	return max(l, default=0)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def f(x):
	s = str(x)
	return x // 10 + min(x, 9) - (s[0] > s[-1])

def main():
	(l, r) = sep()
	print(f(r) - f(l - 1))
main()


def ff(num):
	return int(num) // 10 - (0 if int(str(num)[0]) <= int(str(num)[-1]) else 1) + 9 if int(num) >= 10 else int(num)

def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[l, r] = get()
	print(ff(r) - ff(l - 1))
	if mode == 'file':
		f.close()
main()


(l, r) = map(int, input().split())
l = l - 1 if l < 10 else l // 10 + 8 + (str(l)[-1] > str(l)[0])
r = r if r < 10 else r // 10 + 8 + (str(r)[-1] >= str(r)[0])
print(r - l)


(l, r) = input().split()

def f(n):
	(l, k) = (len(n), int(n))
	if l == 1:
		return k
	(a, b) = (int(n[0]), int(n[l - 1]))
	if l == 2:
		return 9 + a - int(b < a)
	return 9 + a * 10 ** (l - 2) - int(b < a) + int(n[1:l - 1])
print(f(r) - f(str(int(l) - 1)))