#!/usr/bin/env python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import lru_cache @lru_cache(None) def count12(L, R): if L == R: return str(L).count('12') if L > R: return 0 x = (L - 12 + 99) // 100 y = (R - 12) // 100 ret = y - x + 1 for i in range(10): x = (L - i + 9) // 10 y = (R - i) // 10 ret += count12(x, y) return ret def count12_naive(L, R): return sum(str(n).count('12') for n in range(L, R + 1)) def count_2xx1(L, R): def count_2xx(L, R): ret = 0 for keta in range(0, 20): low = 2 * (10 ** keta) high = 3 * (10 ** keta) - 1 if low < L: low = L if high > R: high = R if low <= high: ret += high - low + 1 return ret x = (L - 1 + 9) // 10 y = (R - 1) // 10 return count_2xx(x, y) def count_2xx1_naive(L, R): return sum(str(n)[0] == '2' and n % 10 == 1 for n in range(L, R + 1)) def solve(A, B): ret = count12(A, B) if A < B: ret += count_2xx1(A, B - 1) if A <= 1 and 2 <= B: ret += 1 return ret A, B = map(int, read().split()) print(solve(A, B))