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.

Difficulty: MEDIUM
Tags: Dynamic programming

Sorting

Combinatorics
Skill types: Dynamic programming

Sorting

Starter code:

Solutions:
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()


def get(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(get(r) - get(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))


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))


(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))


a1 = list(map(int, input().split()))
if (a1[0] < 10) & (a1[1] < 10):
	print(a1[1] - a1[0] + 1)
elif a1[0] < 10:
	b = a1[1] - int(str(a1[1])[-1])
	ans = 10 - a1[0] + b // 10
	if str(a1[1])[0] > str(a1[1])[len(str(a1[1])) - 1]:
		ans -= 1
	else:
		pass
	print(ans)
else:
	b1 = a1[0] - int(str(a1[0])[-1])
	b2 = a1[1] - int(str(a1[1])[-1])
	ans = (b2 - b1) // 10 + 1
	if str(a1[0])[0] < str(a1[0])[len(str(a1[0])) - 1]:
		ans -= 1
	if str(a1[1])[0] > str(a1[1])[len(str(a1[1])) - 1]:
		ans -= 1
	print(ans)


import sys
import math as m
p = [0] * 20

def fi():
	return sys.stdin.readline()

def check(n):
	ans = 0
	ans += min(9, n)
	for i in range(10):
		if i:
			if 10 * i + i <= n:
				ans += 1
	for i in range(3, 19):
		for j in range(1, 10):
			no = p[i - 1] * j + j
			lo = -1
			hi = p[i - 2]
			res = 0
			while hi - lo > 1:
				mid = (lo + hi) // 2
				if mid * 10 + no <= n:
					lo = mid
				else:
					hi = mid
			ans += lo + 1
	return ans
p[0] = 1
for i in range(1, 19):
	p[i] = p[i - 1] * 10
(l, r) = map(int, fi().split())
ans = check(r) - check(l - 1)
print(ans)


(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 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()


(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])


(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)