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.

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.

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

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

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

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)

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 get(x):
	if x <= 9: return x
	ans = 0
	s = str(x)
	for i in xrange(1, len(s)):
		ans += 9 * (1 if 1 == i else 10 ** (i - 2))
	ans += (ord(s[0]) - ord('0') - 1) * (10 ** (len(s) - 2))
	mid = int(s[1:-1]) if len(s) > 2 else 0
	ans += mid + 1 if s[-1] >= s[0] else mid
	return ans

def main():
	left, right = map(int, raw_input().split())
	print get(right) - get(left - 1)

if __name__ == "__main__": main()

p = [0, 1, 1]
p.extend([10 ** x for x in range(1,19)])
#print(p)
#a, b = input().split()
#I need to find the num which are smaller then this

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(ca)
# print(cb)
print(cb - ca + 1 if a[0] == a[-1] else cb - ca  )
# base = p[len(num)]

# result = 0
# i = 1
# while  i < len(num):
# 	result += p[i] * 9
# 	i += 1

# start = int(num[0])
# end = int(num[-1])

# result += (start - 1) * (p[len(num) - 2] * 9)
# if start <= end:
# 	result += int(num[1:-1]) + 1

def f(x):
	if x < 10:
		return x
	count = x/10 + 9
	if int(str(x)[0]) > int(str(x)[-1]):
		count -= 1
	return count
a, b = map(int, raw_input().split())
print f(b) - f(a - 1)

l=lambda:map(int,raw_input().split())
a,b=l()
def fun(x):
    if x<10:
        return x
    r=x%10
    if int(str(x)[0])>r:
        return x/10-1+9
    else:
        return x/10+9
print fun(b)-fun(a-1)

l,r=map(int,raw_input().split())
def get(x): return x if x<10 else (x/10+8+(0 if str(x)[0]>str(x)[-1] else 1))
print get(r)-get(l-1)

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 f(s):
  if s == '0':
    return 0
  n = len(s)
  if n > 2:
    sum = '9' * (n-2)
    sum = int(sum) + 9
  elif n == 2:
    sum = 9
  else:
    sum = int(s)

  ss = s[0]
  cs = int(s)
  cs -= 10**(n-1)
  s = str(cs)
  n = len(s)

  for si in s[:-1]:
    sum += int(si) * 10**(n-2)
    n -= 1
  if int(s[-1]) >= int(ss):
    sum += 1
  return sum

l, r = map(int, raw_input().split())
print f(str(r)) - f(str(l-1))

#! python

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

    # length > 2

    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)

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

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

#!/usr/bin/env python

l,r = map(int, raw_input().strip().split())

p = [1]
for i in xrange(1,20):
    p.append(p[-1]*10)

d = [0,9,18]
for i in xrange(3,20):
    d.append(d[i-1]+p[i-2]*9)

def cal(x):
    if x<10: return x
    elif x<100: return d[1] + x/11
    else:
        s = str(x)
        n = len(s)
        k = int(s[0]) - 1
        tmp = d[n-1] + k*p[n-2]
        tmp+=int(s[1:-1])
        if s[0]<=s[-1]:
            tmp+=1
        return tmp

res = cal(r)-cal(l)
s = str(l)
if s[0]==s[-1]:
    res +=1

print res

def power(a,b):
	x=1
	y=a
	while b!=0:
		if b%2==1:
			x=x*y
		y=y*y
		b=b/2
	return x
def ret(s,rl):
	rr=0
	k=int(s[0])
	rr=(k-1)*power(10,rl-2)
	for i in range(1,rl):
		if i==rl-1:
			if int(s[i]) >= int(s[0]):
				rr=rr+1
		else:
			k=int(s[i])
			rr=rr+(k)*power(10,rl-2-i)
	return rr
s=raw_input()
ll=s.split()
l=str(int(ll[0])-1)
r=ll[1]
rl=len(r)
ll=len(l)
if rl==1:
	ansr=int(r)
	ansl=int(l)
	print ansr-ansl
else:
	ansr=9
	i=2
	while i < rl:
		ansr=ansr+9*power(10,i-2)
		i=i+1
	ansr=ansr+ret(r,rl)
	if ll==1:
	   	ansl=int(l)
	else:
		ansl=9
		i=2
		while i < ll:
			ansl=ansl+9*power(10,i-2)
			i=i+1
		ansl=ansl+ret(l,ll)
	print ansr-ansl

#!/usr/bin/env python

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

a,b = map(int,raw_input().split())
print f(b) - f(a-1)

# n=int(input())
# n,k=map(int,input().split())
# arr=list(map(int,input().split()))
#ls=list(map(int,input().split()))
#for i in range(m):
# for _ in range(int(input())):
from collections import Counter
#from fractions import Fraction
#n=int(input())
#arr=list(map(int,input().split()))
#ls = [list(map(int, input().split())) for i in range(n)]
from math import log2
#for _ in range(int(input())):
#n, m = map(int, input().split())
'''n, m = map(int, input().split())
g=[]
for i in range(n):
    s=input()
    g.append(s)'''
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))

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 cal(n):
    if int(n) < 10:
        return int(n)
    else:
        if n[0] <= n[-1]:
            return int(n) // 10 + 9
        else:
            return int(n) // 10 + 8

l,r = map(int, raw_input().split())
print cal(str(r)) - cal(str(l-1))

#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
#from __future__ import print_function, division    #while using python2
# from itertools import accumulate
# from collections import defaultdict, Counter

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
        # print("i = ", i, ", k = ", k)
        ans += (k * (10 ** x))
        x -= 1
        if x < 0:
            break
    if int(s[-1]) >= int(s[0]):
        ans += 1
    return ans

def main():
    #sys.stdin = open('input.txt', 'r')
    #sys.stdout = open('output.txt', 'w')

    # print(get_numbers(input()))

    l, r = [int(x) for x in input().split()]
    # print(get_numbers(str(l-1)))
    # print(get_numbers(str(r)))

    print(get_numbers(str(r)) - get_numbers(str(l-1)))

#------------------ Python 2 and 3 footer by Pajenegod and c1729-----------------------------------------
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')

if __name__ == '__main__':
   main()

# coding=utf-8
from __future__ import division, print_function
import math
import sys

def count(n):
    #print("")
    #print(n)
    if n < 10:
        return n
    cnt = 9
    ns = str(n)
    for i in range(len(ns)-1):
        for d in range(1, 10):
            m = int("{0}{1}{0}".format(d, "9"*i))
            #print(i, d, m, cnt)
            if m <= n:
                cnt += 10**i
            else:
                if int(ns[0]) >= d:
                    cnt += int(ns[1:-1] if len(ns) > 2 else 0)
                    if int(ns[-1]) >= d:
                        cnt += 1
                return cnt
    return cnt

eps = 0.0000001
if __name__ == "__main__":
    l, r = map(int, sys.stdin.readline().split())
    print("{0}".format(count(r) - count(l-1)))

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

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

main()

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

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

n,m=raw_input().split()
def F(x):
    return int(x) if len(x)==1 else (int(x[0]) <= int(x[-1])) + int(x)/10+8
print F(m) - F(str(int(n)-1))

l,r=map(int,raw_input().split())
def get(x): return x if x<10 else (x/10+8+(0 if str(x)[0]>str(x)[-1] else 1))
print get(r)-get(l-1)

l=lambda:map(int,raw_input().split())
a,b=l()
def fun(x):
    if x<10:
        return x
    r=x%10
    if int(str(x)[0])>r:
        return x/10-1+9
    else:
        return x/10+9
print fun(b)-fun(a-1)

def check(x):
    return str(x)[0]==str(x)[-1]
l,r=map(int,raw_input().split())
res=0
while (l%10!=0)and(r>=l):
    if check(l):
        res+=1
    l+=1
while (r%10!=9)and(r>=l):
    if check(r):
        res+=1
    r-=1
res+=(r-l+1)/10
print res

read = raw_input
readints = lambda: map(int, read().split())
range = xrange

def F(n):
    if int(n) < 10:
        return int(n)
    else:
        if n[0] <= n[-1]:
            return int(n) // 10 + 9
        else:
            return int(n) // 10 + 8

l, r = readints()
print F(str(r)) - F(str(l - 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)

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

#! python

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

    # length > 2

    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)

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

def digit(c):
    return ord(c)-ord('0')
def calc(n):
    if len(n) == 1:
        return digit(n[0])
    elif len(n) == 2:
        return 9 + digit(n[0]) - 1 + int(digit(n[0])<=digit(n[1]))
    else:
        ans = 0
        for m in xrange(1, len(n)+1):
            if m == 1:
                ans += 9
            elif m != len(n):
                ans += 9*(10**(m-2))
            else:
                ans += (digit(n[0])-1)*(10**(m-2)) + int(n[1:-1]) + int(digit(n[0])<=digit(n[-1]))
        return ans
l, r = raw_input().strip().split()
print calc(r)-calc(str(int(l)-1))

def help(x):
    if x<=9:
        return x
    arr=list(str(x))
    ans=0
    for i in range(1,len(arr)):
        ans+=help2(i)

    #print ans
    ans+=(10**(len(arr)-2))*(int(arr[0])-1)
    #print ans
    a=int(arr[0])
    b=int(arr[-1])
    arr=arr[1:]
    arr=arr[:-1]
    num=0
    if len(arr)>0:
        num+=int(''.join(arr))
    if b>=a:
        ans+=(num+1)
    else:
        ans+=num
    return ans

def help2(i):
    if i==1:
        return 9
    else:
        return 9*(10**(i-2))

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

print help(r)-help(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(ans1, ans2)

print(func(b) - func(a))

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

def power(a,b):
	x=1
	y=a
	while b!=0:
		if b%2==1:
			x=x*y
		y=y*y
		b=b/2
	return x
def ret(s,rl):
	rr=0
	k=int(s[0])
	rr=(k-1)*power(10,rl-2)
	for i in range(1,rl):
		if i==rl-1:
			if int(s[i]) >= int(s[0]):
				rr=rr+1
		else:
			k=int(s[i])
			rr=rr+(k)*power(10,rl-2-i)
	return rr
s=raw_input()
ll=s.split()
l=str(int(ll[0])-1)
r=ll[1]
rl=len(r)
ll=len(l)
if rl==1:
	ansr=int(r)
	ansl=int(l)
	print ansr-ansl
else:
	ansr=9
	i=2
	while i < rl:
		ansr=ansr+9*power(10,i-2)
		i=i+1
	ansr=ansr+ret(r,rl)
#print ansr
	if ll==1:
	   	ansl=int(l)
	else:
		ansl=9
		i=2
		while i < ll:
			ansl=ansl+9*power(10,i-2)
			i=i+1
		ansl=ansl+ret(l,ll)
#	print ansl
	print ansr-ansl

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

rdi = lambda: list(map(int, input().split()))

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

l, r = rdi()
print(f(r)-f(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 LB(l,d,lim):
	s,e = 0,10**l - 1;
	while s < e:
		m = (s + e) >> 1;
		f = str(m);
		f = "0"*(l - len(f)) + f;
		f = int(str(d) + f + str(d));
		if f >= lim: e = m;
		else : s = m + 1;
	f = str(s);
	f = "0"*(l - len(f)) + f;
	f = int(str(d) + f + str(d));
	return s + (f < lim);

def get(l,d,x,y):
	#if l == 2 and d == 1: print LB(l,d,y + 1) ,LB(l,d,x)
	return LB(l,d,y + 1) - LB(l,d,x);

x,y = map(int,raw_input().split());
ans = max(min(y,9) - max(x,1) + 1,0);
#print ans;
for l in xrange(18):
	if l:
		for d in xrange(1,10):
			tmp = get(l,d,x,y);
			ans += tmp;
	#		print l,d,tmp;
	else:
		tmp = 11;
		while tmp <= 99:
			ans += (x <= tmp) and (tmp <= y);
			tmp += 11;
print ans;

import sys
l,r=map(int,raw_input().split())

def solve(b):
  ok=False
  while not ok:
    s=str(b)
    ok=s[0]==s[-1]
    if not ok:
      b-=1

  res=0
  for k in range(100):
    if str(k)[0]==str(k)[-1] and k<=b:
      res+=1;
  lb=len(str(b))
  for l in range(3,lb+1):

    if l<lb:
      res+= 9*10**(l-2)
    if l==lb:
      for d in range(1,10):
        if d<b%10:
          res+=10**(l-2)
        if d==b%10:
          res+=1+int(str(b)[1:-1])
  return res

print solve(r)-solve(l-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)

#------------------------template--------------------------#
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-6
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()]

#-------------------------code---------------------------#
# vsInput()

length_wise=[0,10,19]

for i in range(3,19):
    length_wise.append(9*(10**(i-2))+length_wise[-1])

# print(length_wise)

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

    # print(key,ans)

    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

    # print(ans,ans1,x)

    return ans+ans1

l,r=value()

# print(operate(l-1))
# print(operate(r))

print(operate(r)-operate(l-1))

# BruteForce
# ans=0
#
# for i in range(l,r+1):
#     x=str(i)
#     if(x[0]==x[-1]):
#         # print(x)
#         ans+=1

# print(ans)

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

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

#!/usr/bin/env python

l,r = map(int, raw_input().strip().split())

p = [1]
for i in xrange(1,20):
    p.append(p[-1]*10)

d = [0,9,18]
for i in xrange(3,20):
    d.append(d[i-1]+p[i-2]*9)

def cal(x):
    if x<10: return x
    elif x<100: return d[1] + x/11
    else:
        s = str(x)
        n = len(s)
        k = int(s[0]) - 1
        tmp = d[n-1] + k*p[n-2]
        tmp+=int(s[1:-1])
        if s[0]<=s[-1]:
            tmp+=1
        return tmp

res = cal(r)-cal(l)
s = str(l)
if s[0]==s[-1]:
    res +=1

print res

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

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

l,r=map(int,raw_input().split())
def get(x): return x if x<10 else (x/10+8+(0 if str(x)[0]>str(x)[-1] else 1))
print get(r)-get(l-1)

a, b =  raw_input().split()

def val(pos):
	ans = 10
	for i in range(pos):
		ans += 9 * (10**i)
	return ans

def calc(x):
	if len(x) == 1:
		return int(x) + 1
	else:
		bef = val(len(x) - 2)
		now = (int(x[0]) - 1) * (10**(len(x) - 2))
		mid = x[1:-1]
		if len(mid) == 0:
			mid = 1
		else:
			mid = int(mid) + 1
		return bef + now + mid

def nume(x):
	x = int(x)
	for i in range(11):
		b = str(x)
		if b[0] == b[-1]:
			return b
		x = x - 1

a = int(a) - 1
b = int(b)
a = nume(str(a))
b = nume(str(b))

print calc(b)- calc(a)

def help(x):
    if x<=9:
        return x
    arr=list(str(x))
    ans=0
    for i in range(1,len(arr)):
        ans+=help2(i)

    #print ans
    ans+=(10**(len(arr)-2))*(int(arr[0])-1)
    #print ans
    a=int(arr[0])
    b=int(arr[-1])
    arr=arr[1:]
    arr=arr[:-1]
    num=0
    if len(arr)>0:
        num+=int(''.join(arr))
    if b>=a:
        ans+=(num+1)
    else:
        ans+=num
    return ans

def help2(i):
    if i==1:
        return 9
    else:
        return 9*(10**(i-2))

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

print help(r)-help(l-1)

def match(x):
    if x < 10:
        return x
    if x < 100:
        return 9 + x / 10 - (1 if x / 10 > x % 10 else 0)

    tmp = 1
    while tmp <= x:
        tmp *= 10
    tmp /= 10
    ans = tmp/10 + 8
    ans += tmp/10 * (x/tmp - 1)
    ans += (x % tmp) / 10
    if x / tmp <= x % 10:
        ans += 1
    return ans

[l, r] = [int(x) for x in raw_input().split()]
print match(r) - match(l-1)

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

#! /usr/bin/env python
#  @author : grastyele

from math import (log10, ceil, floor)

def solve(x):
    if x < 10:
        return x
    ret = 0
    w = 0
    y = x / 10
    while y > 0:
        w = w + 1
        y = y / 10
    f = x / (10 ** w)
    if x % 10 >= f:
        ret = ret + 1
    for i in xrange(2, w + 1):
        ret = ret + 9 * (10 ** (i - 2))
    ret = ret + (f - 1) * (10 ** (w - 1))
    ret = ret + x % (10 ** w) / 10
    return ret + 9

if __name__ == "__main__":
    x, y = map(int, raw_input().split())
    print solve(y) - solve(x - 1)

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

def sol():
    lower, upper = map(int, raw_input().split())
    res = 0
    for val in range(1, 10):
        if lower <= val <= upper: res+=1
    for length in range(2, 19):
        for startend in range(1, 10):
            alreadyval = startend * pow(10, length - 1) + (0 if length == 1 else startend)
            smallestpos = max(0, (lower - alreadyval + 9) / 10)
            largestpos = min(pow(10, length - 2) - 1, (upper - alreadyval) / 10)
            res += max(0, largestpos - smallestpos + 1)
    print(res)
sol()

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")
    #f.readline()
    #input()
    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()

if __name__=="__main__":
    main()

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

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 f(s):
  if s == '0':
    return 0
  n = len(s)
  if n > 2:
    sum = '9' * (n-2)
    sum = int(sum) + 9
  elif n == 2:
    sum = 9
  else:
    sum = int(s)

  ss = s[0]
  cs = int(s)
  cs -= 10**(n-1)
  s = str(cs)
  n = len(s)

  for si in s[:-1]:
    sum += int(si) * 10**(n-2)
    n -= 1
  if int(s[-1]) >= int(ss):
    sum += 1
  return sum

l, r = map(int, raw_input().split())
print f(str(r)) - f(str(l-1))

l,r=map(int,raw_input().split())
res=0

while (l%10!=0)and(r>=l):
    if str(l)[0]==str(l)[-1]:
        res+=1
    	#print l
    l+=1
while (r%10!=9)and(r>=l):
    if str(r)[0]==str(r)[-1]:
        res+=1
        #print r
    r-=1
res+=(r-l+1)/10
print res

rdi = lambda: list(map(int, input().split()))

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

l, r = rdi()
print(f(r)-f(l-1))

from math import pow

def stripped_line():
    return raw_input().strip()

def read_ints():
    return map(int, stripped_line().split())

def total(l):
    diff = l - 2
    if l in (1, 2):
        diff = 0
    result = int(pow(10, diff) * 9)
    return result

def total_to(v):
    as_s = str(v)
    if len(as_s) == 1:
        return v
    if len(as_s) == 2:
        if v == 10:
            return 0
        r = int(as_s[0]) - 1
        if int(as_s[1]) >= int(as_s[0]):
            r += 1
        return r
    else:
        l = len(as_s)
        r = ((int(as_s[0])) - 1) * int(pow(10, l - 2))
        if int(as_s[0]) == 1:
            r = 0
        if int(as_s[-1]) >= int(as_s[0]):
            r += 1
        r += int(as_s[1:-1])
        return r

def total_from(v):
    r = total(len(str(v))) - total_to(v)
    as_s = str(v)
    if as_s[0] == as_s[-1]:
        r += 1
    return r

f, t = read_ints()

fl, tl = len(str(f)), len(str(t))
result = 0
for i in range(fl, tl + 1):
    if fl == tl:
        result = total(fl) - ((total(fl) - total_from(f)) + (total(fl) - total_to(t)))
        break
    if i == fl:
        result += total_from(f)
    elif i == tl:
        result += total_to(t)
    else:
        result += total(i)

print result

one = [0,9,9]
x = 9
for i in xrange(18):
    x*=10
    one+=[x]
cone =[0]
x = 0
for i in one[1:]:
    x+=i
    cone+=[x]
l,r = raw_input().split()
l=str(int(l)-1)
rl = len(r)
rs = cone[rl-1]
if(True):
    if(rl==1):
        rs += int(r)
    elif(rl==2):
        if(r[0]>r[1]):
            temp = (int(r[0])-1)*(one[rl]/9)
        else:
             temp = (int(r[0]))*(one[rl]/9)
        rs+=temp
    else:
        temp = (int(r[0])-1)*(one[rl]/9)
        rs+=temp
        if(rl>2):
            extra = int(r[1:-1])+1
            if(r[0]>r[-1]):
                extra-=1
            rs+=extra
ll = len(l)
ls = cone[ll-1]
if(True):
    if(ll==1):
        ls += int(l)
    elif(ll==2):
        if(l[0]>l[1]):
            temp = (int(l[0])-1)*(one[ll]/9)
        else:
             temp = (int(l[0]))*(one[ll]/9)
        ls+=temp
    else:
        temp = (int(l[0])-1)*(one[ll]/9)
        ls+=temp
        if(ll>2):
            extra = int(l[1:-1])+1
            if(l[0]>l[-1]):
                extra-=1
            ls+=extra
print rs-ls

#########			##	##     ##    	  ####  #####  ##     #  ##     #		##
	#			   # #	# #   # #		 #	  #	#	#  # #    #  # #    #	   # #
	#			  #  #	#  ###  #	    #		#	#  #  #   #  #  #   #	  #  #
	#			 #####	#	#	#	   #    ###	#	#  #   #  #  #   #  #    #####
	#			#    #	#		#	   #    # #	#	#  #	# #  #	  # #   #    #
######### 	   #     # 	#		#		##### #	#####  #	 ##  #	   ##  #     #

"""

PPPPPPP       RRRRRRR		    OOOO	  VV        VV    EEEEEEEEEE
PPPPPPPP      RRRRRRRR         OOOOOO     VV       VV	  EE
PPPPPPPPP     RRRRRRRRR       OOOOOOOO    VV      VV	  EE
PPPPPPPP      RRRRRRRR        OOOOOOOO    VV     VV    	  EEEEEE
PPPPPPP       RRRRRRR         OOOOOOOO    VV    VV        EEEEEEE
PP  		  RRRR			  OOOOOOOO    VV   VV         EEEEEE
PP			  RR  RR          OOOOOOOO    VV  VV          EE
PP			  RR    RR         OOOOOO     VV VV           EE
PP			  RR      RR        OOOO      VVVV            EEEEEEEEEE

"""

"""
 Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.
"""
import sys
input = sys.stdin.readline
read = lambda: map(int, input().split())
# from bisect import bisect_left as lower_bound;
# from bisect import bisect_right as upper_bound;
# from math import ceil, factorial;

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

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp;

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

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

## nCr function efficient using Binomial Cofficient
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)

## upper bound function code -- such that e in a[:i] e < x;
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;

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    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
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
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

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b;

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
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;

# the union function which makes union(x,y)
# of two nodes x and y
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

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
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

# Euler's Toitent Function phi
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

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e5 + 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;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
spf = [0 for i in range(MAXN)]
# spf_sieve();
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
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

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

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()));

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

## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

from itertools import permutations
import math

from bisect import bisect_left

def calc(x):
	# print(x // 10)
	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))

if __name__ == '__main__':
	for _ in range(1):
		solve()
	# fin_time = datetime.now()
# 	print("Execution time (for loop): ", (fin_time-init_time))

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

# author: sharrad99
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 check(x): return str(x)[0]==str(x)[-1]
l,r=map(int,raw_input().split())
res=0
while (l%10!=0)and(r>=l):
	if check(l):
		res+=1
	l+=1
while (r%10!=9)and(r>=l):
	if check(r):
		res+=1
	r-=1
res+=(r-l+1)/10
print res

#!/usr/bin/python

def ini():
        global a
        a[1] = 9
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10
#	print a

def get_number(n):
        global a
        num = len(str(n))
#	print 'num === ',num
        ans = 0
        for i in range(1,num):
                ans += a[i]
#	print ans
        if(num == 1):
                ans += n
        elif num == 2:
                if(n // 10 > n % 10) :
                        ans += (n // 10 - 1)
                else:
                        ans += (n // 10)
        else:
                m = str(n)
                start = int(m[0:1])
                end = n % 10
                ans += (start - 1) * (a[num] / 9)
                if(start <= end):
                        ans += int(m[1:-1]) + 1
                else:
                        ans += int(m[1:-1])
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#! python

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

    # length > 2

    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)

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)
print(t[r] - t[l - 1])

#!/usr/bin/env python

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

a,b = map(int,raw_input().split())
print f(b) - f(a-1)

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

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

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))
    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(till(r) - till(l)+good(l))

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

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-pow(10,len(s)-2)
    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)
    #print(r)
    rc=rc+int(s[1:-1])+1
    #print(int(s[1:-1])+1)
    r=r-pow(10,len(s)-2)
    l=r-1
    #print(r)

while r!=0:
    s=str(r)
    if s[0]==s[-1]:
        rc=rc+1
        r=r-1
    else:
        r=r-1

print(rc-lc)

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
            #print(s)
    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:
        return ( 9 + min( x//10, x%10 ) )
    else:
        ret = int( "1" + "0"*(L-3) + "8" )
        num = list( str(x) )
        #print( num )
        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
        #print( 'num',num )
        #print( 'd', d )
        #print( 'num', num, 'ret before', ret )
        ret += ( int(d-1) ) * int( "9" * (L-2) ) + int( num[1:-1] ) + int(d)

    return ( ret )

#print( cnt(1024), cnt2(1024) )
#print( cnt(47), cnt2(47) )
#print( cnt(9), cnt2(9) )
#print( cnt(58), cnt2(58) )
#print( cnt(999), cnt2(999) )
#print( cnt(8987), cnt2(8987) )
#print()
#print( cnt(99999), cnt2(99999) )
#print( cnt(99899), cnt2(99899) )
#print( cnt(1000), cnt2(1000) )
#print( cnt2(1) )
#exit(0)

print( cnt2(r) - cnt(l-1) )

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

def f( x, fl ):

    #print( 'x', x )
    L = len(x)
    if L <= 0:
        #print( "terminate" )
        return 0
    if L <= 1:
       return int(x)

    if fl:
        d = min( int(x[0]), int(x[-1]) )
    else:
        d = max( int(x[0]), int(x[-1]) )
    if d == 0:
        #print( "\td is 0")
        return f(  "9" + x[1:-1] + "9", False )
    ans = d
    if L >= 3:
        #print(' l', (L-2)//2 + 1, ans )
        for i in range( (L-2)//2+1 ):
            ans *= 10
        #print(ans)
    if L >= 2:
        ans += f( x[1:-1], False )
        if L == 2:
            ans += f( "9", False )

    return ( ans )

print( f( str(r), True ) - f( str(l-1), True ) )

import bisect
l,r=list(map(int,input().split()))
ans=0
for i in range(len(str(l))+1,len(str(r))):
    ans=ans+9*(10**(i-2))
a1,a2=[],[]
for i in range(1,10):
    s=str(i)+'0'*(max(0,len(str(l))-2))+str(i)
    a1.append(int(s))
    s=str(i)+'0'*(max(0,len(str(r))-2))+str(i)
    a2.append(int(s))
j=bisect.bisect_left(a1,l)
ans=ans+(9-j)*(10**(max(0,len(str(l))-2)))
j=bisect.bisect_right(a2,r)
ans=ans+(j-1)*(10**(max(0,len(str(r))-2)))

if j<len(str(a2)) and str(r)[0]==str(a2[j])[0]:
    ans=ans+10**(max(0,len(str(r))-2))
else:
    for i in range(1,len(str(r))-1):
        ans=ans+int(str(r)[i])*(10**(len(str(r))-2-i))
    if len(str(r))>=3:
        ans=ans+1
print(ans)

import bisect
l,r=list(map(int,input().split()))
ans=0
for i in range(len(str(l))+1,len(str(r))):
    ans=ans+9*(10**(i-2))
a1,a2=[],[]
for i in range(1,10):
    s=str(i)+'0'*(max(0,len(str(l))-2))+str(i)
    a1.append(int(s))
    s=str(i)+'0'*(max(0,len(str(r))-2))+str(i)
    a2.append(int(s))
j=bisect.bisect_left(a1,l)
ans=ans+(9-j)*(10**(max(0,len(str(l))-2)))
j=bisect.bisect_right(a2,r)
ans=ans+(j-1)*(10**(max(0,len(str(r))-2)))

if j<len(str(a2)) and str(r)[0]==str(a2[j])[0]:
    ans=ans+10**(max(0,len(str(r))-2))
else:
    for i in range(1,len(str(r))-1):
        ans=ans+int(str(r)[i])*(10**(len(str(r))-2-i))
print(ans+1)

import bisect
l,r=list(map(int,input().split()))
ans=0
for i in range(len(str(l))+1,len(str(r))):
    ans=ans+9*(10**(i-2))
a1,a2=[],[]
for i in range(1,10):
    s=str(i)+'0'*(max(0,len(str(l))-2))+str(i)
    a1.append(int(s))
    s=str(i)+'0'*(max(0,len(str(r))-2))+str(i)
    a2.append(int(s))
j=bisect.bisect_left(a1,l)
ans=ans+(9-j)*(10**(max(0,len(str(l))-2)))
j=bisect.bisect_right(a2,r)
ans=ans+(j-1)*(10**(max(0,len(str(r))-2)))

if j<len(str(a2)) and str(r)[0]==str(a2[j])[0]:
    ans=ans+10**(max(0,len(str(r))-2))
else:
    for i in range(1,len(str(r))-1):
        ans=ans+int(str(r)[i])*(10**(len(str(r))-2-i))
    if len(str(r))>=3:
        ans=ans+1
    if int(str(r)[0])>int(str(r)[-1]):
        ans=ans-1
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)>=3:
            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)

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

def f(x):
    x = list(map(int, x))
    a = len(x)
    ans = 0
    for i in range(1, a):
        ans += 9* math.pow(10, max(0, i-2))

    ans += (x[0]-1)* 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))))

#! python

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

    # length > 2

    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(count(r) - count(l) + 1)

rdi = lambda: list(map(int, input().split()))

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

l, r = rdi()
print(f(r)-f(l-1))

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

a,b = map(int,input().split())
print(sol(a)-sol(b-1))

def get_count(n):
    lenn = len(str(n))
    if lenn==1:
        return n
    if lenn==2:
        return 9 + n//10
    total=0
    for i in range(1,lenn):
        total+=(max(1,10**(i-2))*9)
    while str(n)[-1]!=str(n)[0]:
        n-=1
    total+=(int(str(n)[1:-1]))
    total+=((int(str(n)[0])-1)*10**(lenn-2))
    return total

def main():
    mode="filee"
    if mode=="file":f=open("test.txt","r")
    #f.readline()
    #input()
    get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
    [l,r] = get()
    print(get_count(r)-get_count(l)+1 - (1 if len(str(l))>2 and str(l)[0]!=str(l)[-1] else 0))

    if mode=="file":f.close()

if __name__=="__main__":
    main()

def get_count(n):
    lenn = len(str(n))
    if lenn==1:
        return n
    if lenn==2:
        return 9 + n//10
    total=0
    for i in range(1,lenn):
        total+=(max(1,10**(i-2))*9)
    while str(n)[-1]!=str(n)[0]:
        n-=1
    total+=(int(str(n)[1:-1]))
    total+=((int(str(n)[0])-1)*10**(lenn-2))
    return total

def main():
    mode="filee"
    if mode=="file":f=open("test.txt","r")
    #f.readline()
    #input()
    get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
    [l,r] = get()
    print(get_count(r)-get_count(l)+1 - (1 if str(l)[0]!=str(l)[-1] else 0))

    if mode=="file":f.close()

if __name__=="__main__":
    main()

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

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

size_l = size(l)
size_r = size(r)

result = int(0)
for i in range(size_l + 1, size_r):
    result += 9 * 10 ** (i - 2)

if size_l != size_r:
    result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))

    result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
    if first(l) >= last(l):
        result += 1

    result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))
    result += cut(r)
    if first(r) <= last(r):
        result += 1

else:
    result += (first(r) - first(l) - 1) * 10 ** (size_r - min(size_r, 2))

    if first(l) != first(r):
        result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
        if first(l) >= last(l):
            result += 1

        result += cut(r)
        if first(r) <= last(r):
            result += 1
    else:
        result += cut(r) - cut(l) - 1
        if cut(r) - cut(l) > 0:
            if first(l) >= last(l):
                result += 1
            if first(r) <= last(r):
                result += 1

print(int(result))

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

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

size_l = size(l)
size_r = size(r)

result = int(0)
for i in range(size_l + 1, size_r):
    result += 9 * 10 ** (i - 2)

if size_l != size_r:
    result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))

    result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
    if first(l) >= last(l):
        result += 1

    result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))
    result += cut(r)
    if first(r) <= last(r):
        result += 1

else:
    result += (first(r) - first(l) - min(1, first(r) - first(l))) * 10 ** (size_r - min(size_r, 2))

    if first(l) != first(r):
        result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
        if first(l) >= last(l):
            result += 1

        result += cut(r)
        if first(r) <= last(r):
            result += 1
    else:
        result += cut(r) - cut(l) - min(1, cut(r) - cut(l))
        if cut(r) - cut(l) > 0:
            if first(l) >= last(l):
                result += 1
            if first(r) <= last(r):
                result += 1

print(int(result))

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

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

size_l = size(l)
size_r = size(r)

result = int(0)
for i in range(size_l + 1, size_r):
    result += 9 * 10 ** (i - 2)

if size_l != size_r:
    result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))

    result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
    if first(l) >= last(l):
        result += 1

    result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))
    result += cut(r)
    if first(r) <= last(r):
        result += 1

else:
    result += (first(r) - first(l) - min(1, first(r) - first(l))) * 10 ** (
                size_r - min(size_r, 2))

    if first(l) != first(r):
        result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
        if first(l) >= last(l):
            result += 1

        result += cut(r)
        if first(r) <= last(r):
            result += 1
    else:
        result += cut(r) - cut(l) - min(1, cut(r) - cut(l))
        if cut(r) - cut(l) > 0:
            if first(l) >= last(l):
                result += 1
            if first(r) <= last(r):
                result += 1
        else:
            if first(l) >= last(l) and first(l) <= last(r):
                result += 1
            if first(r) <= last(r) and first(r) >= last(l):
                result += 1
            if l == r:
                result -= 1

print(int(result))

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

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

size_l = size(l)
size_r = size(r)

result = int(0)
for i in range(size_l + 1, size_r):
    result += 9 * 10 ** (i - 2)

if size_l != size_r:
    result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))

    result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
    if first(l) >= last(l):
        result += 1

    result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))
    result += cut(r)
    if first(r) <= last(r):
        result += 1

else:
    result += (first(r) - first(l) - min(1, first(r) - first(l))) * 10 ** (
                size_r - min(size_r, 2))

    if first(l) != first(r):
        result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1
        if first(l) >= last(l):
            result += 1

        result += cut(r)
        if first(r) <= last(r):
            result += 1
    else:
        result += cut(r) - cut(l) - min(1, cut(r) - cut(l))
        if cut(r) - cut(l) > 0:
            if first(l) >= last(l):
                result += 1
            if first(r) <= last(r):
                result += 1
        else:
            if first(l) >= last(l) and first(l) <= last(r):
                result += 1
            if first(r) <= last(r) and first(r) >= last(l) and l != r:
                result += 1

print(int(result))

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:
            hi = mid
        else:
            lo = mid

    rgt = lo + 1
    if get(n, x, rgt) > r:
        rgt -= 1

    lo = 0
    hi = int("9" * (n - 2))

    while hi - lo > 1:
        mid = (hi + lo) // 2
        if get(n, x, mid) >= l:
            hi = mid
        else:
            lo = mid
    lft = lo
    return rgt - lft + 1

ans = 0
for i in range(1, 20):
    for x in range(1, 10):
        ans += go(i, x)

print(ans)

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

def count(l,L):
    x=0
    if L<=10: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)

p = [0, 1, 1]
p.extend([10 ** x for x in range(1,16)])
#print(p)
#a, b = input().split()
#I need to find the num which are smaller then this

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

		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  )
# base = p[len(num)]

# result = 0
# i = 1
# while  i < len(num):
# 	result += p[i] * 9
# 	i += 1

# start = int(num[0])
# end = int(num[-1])

# result += (start - 1) * (p[len(num) - 2] * 9)
# if start <= end:
# 	result += int(num[1:-1]) + 1

import math
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 = math.floor((r - d - 10 ** (k + 1) * d) / 10)
    lb = math.ceil((l - d - 10 ** (k + 1) * d) / 10)
    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())
ans = (l <= 9) * (9 - l + 1)
for k in range(0, 17):
  for d in range(1, 10):
    rb = math.floor((r - d - 10 ** (k + 1) * d) / 10)
    lb = math.ceil((l - d - 10 ** (k + 1) * d) / 10)
    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())
ans = (l <= 9) * (9 - l + 1)
for d in range(1, 10):
  for k in range(0, 17):
    rb = int(math.floor(r - d - 10 ** (k + 1) * d) / 10)
    lb = int(math.ceil(l - d - 10 ** (k + 1) * d) / 10)
    #print("k = %d, d = %d" % (k, d))
    #print(rb)
    rb = min(10 ** k - 1, rb)
    lb = max(0, lb)
    ans += (rb >= lb) * (rb - lb + 1)
print(ans - 1)

#!/usr/bin/python

def ini():
        global a
        a[1] = 10
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10

def get_number(n):
        global a
        num = len(str(n))
        ans = 0
        for i in range(1,num):
                ans += a[i]
        if(num == 1):
                ans += n
        elif num == 2:
                ans += (n // 10 - 1)
        else:
                m = str(n)
                start = int(m[0:1])
                end = int(m[-2:-1])
                if(start <= end):
                        ans += int(m[1:-1])
                else:
                        ans += int(m[1:-1]) - 1
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#!/usr/bin/python

def ini():
        global a
        a[1] = 10
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10

def get_number(n):
        global a
        num = len(str(n))
        ans = 0
        for i in range(1,num):
                ans += a[i]
        if(num == 1):
                ans += n
        elif num == 2:
                ans += (n // 10 - 1)
        else:
                m = str(n)
                start = int(m[0:1])
                end = int(m[-2:-1])
                if(start <= end):
                        ans += int(m[1:-1]) + 1
                else:
                        ans += int(m[1:-1])
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#!/usr/bin/python

def ini():
        global a
        a[1] = 9
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10

def get_number(n):
        global a
        num = len(str(n))
        ans = 0
        for i in range(1,num):
                ans += a[i]
        if(num == 1):
                ans += n
        elif num == 2:
                ans += (n // 10 - 1)
        else:
                m = str(n)
                start = int(m[0:1])
                end = int(m[-2:-1])
                ans += (start - 1) * (a[num - 2] / 9)
                if(start <= end):
                        ans += int(m[1:-1])
                else:
                        ans += int(m[1:-1])
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#!/usr/bin/python

def ini():
        global a
        a[1] = 9
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10
#	print a

def get_number(n):
        global a
        num = len(str(n))
#	print 'num === ',num
        ans = 0
        for i in range(1,num):
                ans += a[i]
#	print ans
        if(num == 1):
                ans += n
        elif num == 2:
                if(n // 10 > n % 10) :
                        ans += (n // 10 - 1)
                else:
                        ans += (n // 10)
        else:
                m = str(n)
                start = int(m[0:1])
                end = int(m[-2:-1])
                ans += (start - 1) * (a[num] / 9)
                if(start <= end):
                        ans += int(m[1:-1]) + 1
                else:
                        ans += int(m[1:-1])
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#!/usr/bin/python

def ini():
        global a
        a[1] = 10
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10

def get_number(n):
        global a
        num = len(str(n))
        ans = 0
        for i in range(1,num):
                ans += a[i]
        if(num == 1):
                ans += n
        elif num == 2:
                ans += (n // 10 - 1)
        else:
                m = str(n)
                ans += int(m[1:-1])
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#!/usr/bin/python

def ini():
        global a
        a[1] = 9
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10

def get_number(n):
        global a
        num = len(str(n))
        ans = 0
        for i in range(1,num):
                ans += a[i]
        if(num == 1):
                ans += n
        elif num == 2:
                if(n // 10 > n % 10) :
                        ans += (n // 10 - 1)
                else:
                        ans += (n // 10)
        else:
                m = str(n)
                start = int(m[0:1])
                end = int(m[-2:-1])
                ans += (start - 1) * (a[num - 2] / 9)
                if(start <= end):
                        ans += int(m[1:-1]) + 1
                else:
                        ans += int(m[1:-1])
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#!/usr/bin/python

def ini():
        global a
        a[1] = 10
        a[2] = 9
        for i in range(3,19):
                a[i] = a[i - 1] * 10

def get_number(n):
        global a
        num = len(str(n))
        ans = 0
        for i in range(1,num):
                ans += a[i]
        if(num == 1):
                ans += n
        elif num == 2:
                ans += (n // 10 - 1)
        else:
                m = str(n)
                start = int(m[0:1])
                end = int(m[-2:-1])
                if(start <= end):
                        ans += int(m[1:-1])
                else:
                        if(int(m[1:-1]) != 0):
                                ans += int(m[1:-1]) - 1
        return ans

def main():
        left,right = map(int,raw_input().split())
        print get_number(right) - get_number(left - 1)

if __name__ == '__main__':
        global a
        a = [0 for i in range(20)]
        ini()
        main()

#!/usr/bin/env python

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

a,b = map(int,raw_input().split())
print f(b) - f(a-1)

#! /usr/bin/env python
#  @author : grastyele

from math import (log10, ceil, floor)

def solve(x):
    if x < 10:
        return x
    ret = 0
    w = 0
    y = x
    while y > 0:
        w = w + 1
        y = y / 10
    f = x / (10 ** w)
    if x % 10 >= f:
        ret = ret + 1
    for i in xrange(2, w + 1):
        ret = ret + 9 * (10 ** (i - 2))
    ret = ret + (f - 1) * (10 ** (w - 1))
    ret = ret + x % (10 ** w) / 10
    return ret + 9

if __name__ == "__main__":
    x, y = map(int, raw_input().split())
    print solve(y) - solve(x - 1)

#! /usr/bin/env python
#  @author : grastyele

from math import (log10, ceil, floor)

def solve(x):
    if x < 10:
        return x
    ret = 0
    w = int(floor(log10(x)))
    f = x / (10 ** w)
    if x % 10 >= f:
        ret = ret + 1
    for i in xrange(2, w + 1):
        ret = ret + 9 * (10 ** (i - 2))
    ret = ret + (f - 1) * (10 ** (w - 1))
    ret = ret + x % (10 ** w) / 10;
    return ret + 9

if __name__ == "__main__":
    x, y = map(int, raw_input().split())
    print solve(y) - solve(x - 1)

#! /usr/bin/env python
#  @author : grastyele

from math import (log10, ceil, floor)

def solve(x):
    if x < 10:
        return x
    ret = 0
    w = 0
    y = x - 1
    while y > 0:
        w = w + 1
        y = y / 10
    f = x / (10 ** w)
    if x % 10 >= f:
        ret = ret + 1
    for i in xrange(2, w + 1):
        ret = ret + 9 * (10 ** (i - 2))
    ret = ret + (f - 1) * (10 ** (w - 1))
    ret = ret + x % (10 ** w) / 10
    return ret + 9

if __name__ == "__main__":
    x, y = map(int, raw_input().split())
    print solve(y) - solve(x - 1)

#! /usr/bin/env python
#  @author : grastyele

from math import (log10, ceil, floor)

def solve(x):
    if x < 10:
        return x
    ret = 0
    w = int(floor(log10(x)))
    f = x / (10 ** w)
    if x % 10 >= f:
        ret = ret + 1
    for i in xrange(2, w + 1):
        ret = ret + 9 * (10 ** (i - 2))
    ret = ret + (f - 1) * (10 ** (w - 1));
    for j in range(w - 1, 0, -1):
        a = x / (10 ** j) % 10
        ret = ret + a * (10 ** (j - 1))
    return ret + 9

if __name__ == "__main__":
    x, y = map(int, raw_input().split())
    print solve(y) - solve(x - 1)

def prev(n):
    if len(n)==1:
        return 10-int(n)

    if n[0]<n[len(n)-1]:
        ans = 0
        if len(n) > 2:
            ans = 10**(len(n)-2) - int(n[1:len(n) - 1]) -1

        return (9-int(n[0])) *(10**(len(n)-2))+ans
    else:
        ans=0
        if len(n)>2:
            ans=int(n[1:len(n)-1])
        return (10-int(n[0])) *(10**(len(n)-2)) - ans

def nextt(n):
    if len(n)==1:
        return int(n)

    if n[0]>n[len(n)-1]:
        ans=0
        if len(n) > 2:
            ans = int(n[1:len(n) - 1])
        return (int(n[0])-1)* (10 ** (len(n) - 2)) + ans
    else:
        ans = 0
        if len(n) > 2:
            ans = int(n[1:len(n) - 1])
        return (int(n[0])-1)*(10**(len(n)-2))+ ans + 1

l,r=raw_input().split()
ans=prev(l)
ans+=nextt(r)

if(len(l)==len(r)):
    print ans-9
    exit(0)

for i in range(len(l)+1,len(r),1):
    ans+= 9* (10**(i-2))
print ans

def prev(n):
    if len(n)==1:
        return 10-int(n)

    if n[0]<n[len(n)-1]:
        ans = 0
        if len(n) > 2:
            ans = 10**(len(n)-2) - int(n[1:len(n) - 1]) -1

        return (9-int(n[0])) *(10**(len(n)-2))+ans
    else:
        ans=0
        if len(n)>2:
            ans=int(n[1:len(n)-1])
        return (10-int(n[0])) *(10**(len(n)-2)) - ans

def nextt(n):
    if len(n)==1:
        return int(n)

    if n[0]>n[len(n)-1]:
        ans=0
        if len(n) > 2:
            ans = int(n[1:len(n) - 1])
        return (int(n[0])-1)* (10 ** (len(n) - 2)) + ans
    else:
        ans = 0
        if len(n) > 2:
            ans = int(n[1:len(n) - 1])
        return (int(n[0])-1)*(10**(len(n)-2))+ ans + 1

l,r=raw_input().split()
ans=prev(l)

ans+=nextt(r)

if(len(l)==len(r)):
    print ans-9* (10**(len(l)-2))
    exit(0)

for i in range(len(l)+1,len(r),1):
    ans+= 9* (10**(i-2))
print ans

def prev(n):
    if len(n)==1:
        return 10-int(n)

    if n[0]<n[len(n)-1]:
        return (9-int(n[0])) *(10**(len(n)-2))
    else:
        ans=0
        if len(n)>2:
            ans=int(n[1:len(n)-1])
        return (10-int(n[0])) *(10**(len(n)-2)) - ans

def nextt(n):
    if len(n)==1:
        return int(n)

    if n[0]>n[len(n)-1]:
        return (int(n[0])-1)* (10 ** (len(n) - 2))
    else:
        ans = 0
        if len(n) > 2:
            ans = int(n[1:len(n) - 1])
        return (int(n[0])) + ans

l,r=raw_input().split()
ans=prev(l)
ans+=nextt(r)
for i in range(len(l)+1,len(r),1):
    ans+= 9* (10**(i-2))
print ans

def sol():
    lower, upper = map(int, raw_input().split())
    res = 0
    for length in range(1, 19):
        for startend in range(1, 10):
            alreadyval = startend * pow(10, length - 1) + (0 if length == 1 else startend)
            smallestpos = max(0, (lower - alreadyval + 9) / 10)
            largestpos = 0 if length <= 1 else min(pow(10, length - 2) - 1, upper, (upper - alreadyval) / 10)
            res += max(0, largestpos - smallestpos + 1)
    print(res)
sol()

def help(x):
    if x<=9:
        return x
    arr=list(str(x))
    ans=0
    for i in range(1,len(arr)):
        ans+=help2(i)

    #print ans
    ans+=(10**(len(arr)-2))*(int(arr[0])-1)
    #print ans
    a=int(arr[0])
    b=int(arr[-1])
    arr=arr[1:]
    arr=arr[:-1]
    num=0
    if len(arr)>0:
        num+=int(''.join(arr))
    if b>=a:
        ans+=(num+1)
    else:
        ans+=num-1
    return ans

def help2(i):
    if i==1:
        return 9
    else:
        return 9*(10**(i-2))

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

print help(r)-help(l-1)

def cnt(L, R, dig, len):

    x = pow(10, len - 1)

    if (L >= (dig + 1) * x):
        return 0

    if (R < dig * x):
        return 0

    left = max(L, dig * x)
    right = min(R, (dig + 1) * x - 1)

    return (right - left + 1)

def main():

    l, r = map(int, raw_input().split(' '))

    i = 0
    while( pow(10,i) <= r ):
        i += 1

    ans = 0

    for dig in range(1,10):
        for len in range(2, i+1):
            L = (l + 10 - dig)/10
            R = (r - dig)/10

            ans += cnt(L, R, dig, len - 1)

        if (dig >= l and dig <= r):
            ans += 1

    print ans

if __name__ == '__main__':
    main()

import sys
l,r=map(int,raw_input().split())

def solve(b):
  ok=False
  while not ok:
    s=str(b)
    ok=s[0]==s[-1]
    if not ok:
      b-=1

  res=0
  for k in range(100):
    if str(k)[0]==str(k)[-1] and k<=b:
      res+=1;
  lb=len(str(b))
  print lb
  for l in range(3,lb+1):

    if l<lb:
      print 9*10**(l-2)
      res+= 9*10**(l-2)
    if l==lb:
      for d in range(1,10):
        if d<b%10:
          res+=10**(l-2)
        if d==b%10:
          res+=1+int(str(b)[1:-1])
  return res

print solve(r)-solve(l-1)

import sys
l,r=map(int,raw_input().split())

def solve(b):
  ok=False
  while not ok:
    s=str(b)
    ok=s[0]==s[-1]
    if not ok:
      b-=1

  res=0
  for k in range(100):
    if str(k)[0]==str(k)[-1] and k<=b:
      res+=1;
  lb=len(str(b))
  for l in range(3,lb+1):
    if l<lb:
      res+= 9*10**(l-2)
    if l==lb:
      res+=1+int(str(b)[1:-1])
  return res

print solve(r)-solve(l-1)

def Cal(length, num):
    length = length - 2
    if length < 0: length = 0
#   print 'cal', locals(), num*10**length
    return num*10**length

def Cal1(num):
#   print 'cal1 start', locals()
    s = str(num)
    if s[0]=='0': return 0
    ans = Cal(len(s), int(s[0])-1)
    ans += (int(s[1:-1])+1) if len(s)>2 else 1
    if s[0]>s[-1]: ans -= 1 if len(s)>2 else 0
#   print 'cal1', locals(), ans
    return ans

def GetResult(l, r):
    ans = 0
    l1 = len(str(l))
    l2 = len(str(r))
    if str(l)[-1]=='0': l += 1
    if l1 == l2: return Cal1(r) - Cal1(l-1)
    for i in range(l1+1, l2):
        ans += Cal(i, 9)
    return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)

try:
    while True:
        l,r = map(int, raw_input().split())
        print GetResult(l, r)
except Exception,e:
    pass

def Cal(length, num):
    length = length - 2
    if length < 0: length = 0
#   print 'cal', locals(), num*10**length
    return num*10**length

def Cal1(num):
    s = str(num)
    if s[0]=='0': return 0
    ans = Cal(len(s), int(s[0])-1)
    if s[0]<=s[-1] and len(s)>=1: ans += (int(s[1:-1])+1) if len(s)>2 else 1
#   print 'cal1', locals(), ans
    return ans

def GetResult(l, r):
    ans = 0
    l1 = len(str(l))
    l2 = len(str(r))
    if str(l)[-1]=='0': l += 1
    if l1 == l2: return Cal1(r) - Cal1(l-1)
    for i in range(l1+1, l2):
        ans += Cal(i, 9)
    return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)

try:
    while True:
        l,r = map(int, raw_input().split())
        print GetResult(l, r)
except Exception,e:
    pass

def Cal(length, num):
    if num<=0: return 0
    length = length - 2
    if length < 0: length = 0
#   print 'cal', locals(), num*10**length
    return num*10**length

def Cal1(num):
    s = str(num)
    ans = Cal(len(s), int(s[0])-1)
    if s[0]<=s[-1] and len(s)>=1: ans += (int(s[1:-1])+1) if len(s)>2 else 1
#   print 'cal1', locals(), ans
    return ans

def GetResult(l, r):
    ans = 0
    l1 = len(str(l))
    l2 = len(str(r))
    if str(l)[-1]=='0': l += 1
    if l1 == l2: return Cal1(r) - Cal1(l-1)
    for i in range(l1+1, l2):
        ans += Cal(i, 9)
        print i, ans
    return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)

l,r = map(int, raw_input().split())
print GetResult(l, r)

def Cal(length, num):
    if num<=0: return 0
    length = length - 2
    if length < 0: length = 0
#   print 'cal', locals(), num*10**length
    return num*10**length

def Cal1(num):
    s = str(num)
    ans = Cal(len(s), int(s[0])-1)
    if s[0]<=s[-1] and len(s)>=1: ans += (int(s[1:-1])+1) if len(s)>2 else 1
#   print 'cal1', locals(), ans
    return ans

def GetResult(l, r):
    ans = 0
    l1 = len(str(l))
    l2 = len(str(r))
    if str(l)[-1]=='0': l += 1
    if l1 == l2: return Cal1(r) - Cal1(l-1)
    for i in range(l1+1, l2):
        ans += Cal(i, 9)
        #print i, ans
    return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)

l,r = map(int, raw_input().split())
print GetResult(l, r)

def LB(l,d,lim):
	s,e = 0,10**l - 1;
	while s < e:
		m = (s + e) >> 1;
		f = str(m);
		f = "0"*(l - len(f)) + f;
		f = int(str(d) + f + str(d));
		if f >= lim: e = m;
		else : s = m + 1;
	f = str(s);
	f = "0"*(l - len(f)) + f;
	f = int(str(d) + f + str(d));
	return s + (f <= lim);

def get(l,d,x,y):
	return LB(l,d,y + 1) - LB(l,d,x);

x,y = map(int,raw_input().split());
ans = max(min(y,9) - max(x,1) + 1,0);
for l in xrange(18):
	if l:
		for d in xrange(1,10):
			tmp = get(l,d,x,y);
			ans += tmp;
	#		print l,d,tmp;
	else:
		tmp = 11;
		while tmp <= 99:
			ans += (x <= tmp) and (tmp <= y);
			tmp += 11;
print ans;

l,r=map(int,input().split())
'''
cnt = 0
for i in range(l,r+1):
    if str(i)[0]==str(i)[-1]: cnt+=1
print(cnt)
def upto_x(n):
    if n<=1000:
        cnt = 0
        for i in range(1,n+1):
            if str(i)[0]==str(i)[-1]: cnt+=1
        return cnt
    s=str(n)
    sm=0
    slen=len(s)
    if slen>=1:
        sm=0
    elif slen>=2:
        sm+=9
    elif slen>=3:
        sm+=10
    else:
        sm=10**(slen-2)
    print(sm)
    now=10**(slen-1)
    now*=int(s[0])
    if s[-1]>=s[0]:
        now+=10**(slen-1)
    sm+=now
    return sm
print(upto_x(r))
print(upto_x(r)-upto_x(l-1))'''
def upto_x(n):
    if n<10:
        return 9
    sm=n//10 +9
    if str(n)[-1]<str(n)[0]:
        sm-=1
    return sm
print(upto_x(r)-upto_x(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, 18):
        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
            #print(str(l_end) + " " + str(r_end))
            #print("     " + str(d_str + '0' * (length - 2 - len(str(l_end))) + str(l_end) + d_str))
            #print("     " + str(d_str + '0' * (length - 2 - len(str(r_end))) + str(r_end) + d_str))
            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)

#!/usr/bin/env python

l,r = map(int, raw_input().strip().split())

p = [1]
for i in xrange(1,20):
    p.append(p[-1]*10)

d = [0,9,18]
for i in xrange(3,20):
    d.append(d[i-1]+p[i-2]*9)

def cal(x):
    if x<10: return x
    elif x<100: return d[1] + x/11
    else:
        s = str(x)
        n = len(s)
        k = int(s[0]) - 1
        tmp = d[n-1] + k*p[n-2]
        if s[0]<=s[-1]:
            tmp+=int(s[1:-1])+1
        return tmp

res = cal(r)-cal(l)
s = str(l)
if s[0]==s[-1]:
    res +=1

print res

#!/usr/bin/env python

def total(num):
	if num == 1:
		return 9
	else:
		return 9*(10**(num-2))

def is_cool(num):
	num = str(num)
	return num[0] == num[-1]

def f(num):
	if num > 99:
		num = str(num)
		l, r = map(int,[num[0], num[-1]])
		s = int(num[1:-1])
		if r == 0:
			res = 0
		else:
			res = (min(l,r)-1)*10**(len(num)-2) + s + 1
		for i in xrange(1,len(num)):
			res = res + total(i)
		return res
	else:
		res = 0
		for i in xrange(1,num+1):
			if is_cool(i):
				res = res + 1
		return res

a,b = map(int,raw_input().split())
print f(b) - f(a-1)

#!/usr/bin/env python

def total(num):
	if num == 1:
		return 9
	else:
		return 9*(10**(num-2))

def is_cool(num):
	num = str(num)
	return num[0] == num[-1]

def f(num):
	if num > 99:
		num = str(num)
		l, r = map(int,[num[0], num[-1]])
		s = int(num[1:-1])
		if r == 0:
			res = 0
		else:
			res = (l-1)*10**(len(num)-2) + s + 1
		for i in xrange(1,len(num)):
			res = res + total(i)
		return res
	else:
		res = 0
		for i in xrange(1,num+1):
			if is_cool(i):
				res = res + 1
		return res

a,b = map(int,raw_input().split())
print f(b) - f(a-1)

def F(x):
	l=len(str(x))
	z=0
	if l==1:
		return x
	elif l==2:
		return x/11+9
	else:
		z=18
	for i in range(3,l):
		z+=9*10**(i-2)
	f=int(str(x)[0])
	z+=(f-1)*10**(l-2)
	g=int()
	g/=10
	z+=g
	h=int(str(f)+str(x)[1:l-1]+str(f))
	print h,x
	if h<=x:
		z+=1
	return z
x,y=map(int,raw_input().split())
print F(y)-F(x-1)

def F(x):
	l=len(str(x))
	z=0
	if l==1:
		return x
	elif l==2:
		return x/11+9
	else:
		z=18
	for i in range(3,l):
		z+=9*10**(i-2)
	f=int(str(x)[0])
	z+=(f-1)*10**(l-2)
	g=int(str(x)[1:])
	g/=10
	z+=g
	h=int(str(f)+str(g)+str(f))
	if h<=x:
		z+=1
	return z
x,y=map(int,raw_input().split())
print F(y)-F(x-1)

def match(x):
    if x < 10:
        return x
    if x < 100:
        return 9 + x / 10 - (1 if x / 10 > x % 10 else 0)

    tmp = 1
    while tmp <= x:
        tmp *= 10
    tmp /= 10
    ans = tmp/10 + 8
    ans += tmp/10 * (x/tmp - 1)
    ans += (x % tmp) / 10
    if x / tmp <= x % 10:
        ans += 1
    return ans

[l, r] = [int(x) for x in raw_input().split()]
print match(l-1)
print match(r)
print match(r) - match(l-1)

l, r = map(int, input().split())
ans, t = 0, dict({l - 1: 0, r: 0})

if l == r:
    exit(print(1))
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] += (9 * int('1' * (le - 2))) * (int(str(num)[0]) - 1)
            break

        le += 1

# print(t)
print(t[r] - t[l - 1])

l, r = map(int, input().split())
ans, t = 0, dict({l - 1: 0, r: 0})

if l == r:
    exit(print(1))
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)
print(t[r] - t[l - 1])

l, r = map(int, input().split())
ans, t = 0, dict({l - 1: 0, r: 0})

if l == r:
    exit(print(1))
for num in [l - 1, r]:
    le = 1
    while True:
        if len(str(num)) > le:
            if le < 3:
                t[num] += 9
            else:
                t[num] += (le - 2) * 10 * 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] += (9 * int('1' * (le - 2))) * (int(str(num)[0]) - 1)
            break

        le += 1

# print(t)
print(t[r] - t[l - 1])