import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write A,B=map(int,readline().split()) B+=1 def solve(x): xx=x X=list(map(int,list(str(x)))) dp=[0]*2 dp_cnt=[0]*2 for i in range(1,X[0]): if i==1: dp_cnt[1]+=1 else: dp_cnt[0]+=1 cnt=0 if X[0]==1: cur=1 else: cur=0 for x in X[1:]: prev=dp prev_cnt=dp_cnt dp=[0]*2 dp_cnt=[0]*2 for i in range(10): if i==1: dp[1]+=prev[0]+prev[1] dp_cnt[1]+=prev_cnt[0]+prev_cnt[1] elif i==2: dp[0]+=prev[0]+prev[1]+prev_cnt[1] dp_cnt[0]+=prev_cnt[0]+prev_cnt[1] else: dp[0]+=prev[0]+prev[1] dp_cnt[0]+=prev_cnt[0]+prev_cnt[1] for i in range(1,10): if i==1: dp_cnt[1]+=1 else: dp_cnt[0]+=1 for i in range(x): if i==1: dp[1]+=cnt dp_cnt[1]+=1 elif i==2: dp[0]+=cnt if cur: dp[0]+=1 dp_cnt[0]+=1 else: dp[0]+=cnt dp_cnt[0]+=1 if x==1: cur=1 elif x==2 and cur: cnt+=1 cur=0 else: cur=0 ans=0 x=xx if x>=3: ans+=1 x+=7 x//=10 le=len(str(x)) for i in range(le-1): ans+=10**i ans+=max(0,min(10**(le-1),x-2*10**(le-1))) return ans+dp[0]+dp[1] ans=solve(B)-solve(A) print(ans)