// Arup Guha
// 12/26/2019
// Solution to 2014 April USACO Silver Problem: Odometer

import java.util.*;
import java.io.*;

public class odometer {
	
	public static HashMap<String,Long> memo;
	public static ArrayList<String> equalList;
	
	public static void main(String[] args) throws Exception {	
		
		// Pre-comp all binary strings with an equal number of 0s and 1s up to 2^18-1.
		equalList = new ArrayList<String>();
		
		// i = bits in #
		for (int i=2; i<=18; i+=2) {
			
			// All #s with i bits.
			for (int j=(1<<(i-1)); j<(1<<i); j++) 
				if (Integer.bitCount(j)*2 == i)
					equalList.add(Integer.toBinaryString(j));
		}
		
		// I am reading these in as strings.
		Scanner stdin = new Scanner(new File("odometer.in"));
		long start = stdin.nextLong()-1;
		long end = stdin.nextLong();

		// To get range, we query all <= high and sub out all <= low.
		long high = wrapper(end+"");
		long low = wrapper(start+"");

		// Output to file.
		PrintWriter out = new PrintWriter(new FileWriter("odometer.out"));
		out.println(high-low);
		out.close();		
		stdin.close();
	}
	
	public static long numEq(String num) {
		
		long res = 0;
		
		// Go through the equal list.
		for (int i=0; i<equalList.size(); i++) {
			
			// All molds automatically work. There are 81 solutions for each mold. 
			// For example, for the mold 1100, we have 9 choices for the 1 (everything but 0), and 9 choices
			// for the 0 (everything but what we chose for 1).
			if (equalList.get(i).length() < num.length()) {
				res += 81;
				continue;
			}
			
			// No more will work.
			if (equalList.get(i).length() > num.length()) break;
			
			// If we get here our mold is the same length as our target string.
			
			// x represents the first digit in the mold. (ie the most significant digit)
			for (char x='1'; x<='9'; x++) {
				
				// y represents the other digit in the mold.
				for (char y='0'; y<='9'; y++) {
					
					// y can't be the same as x.
					if (y == x) continue;
					
					// Run my own compare here.
					int tmp = 1;
					for (int k=0; k<num.length(); k++) {
						char digit = equalList.get(i).charAt(k) == '1' ? x : y;
						if (digit < num.charAt(k)) break;
						if (digit > num.charAt(k)) {tmp = 0; break;}
					}
					
					// Add in this contribution.
					res += tmp;
				}
			}
		}
		
		return res;
	}
	
	// Determines number of moos for values <= num.
	public static long wrapper(String num) {
		
		long res = 0;
		
		memo = new HashMap<String,Long>();
		
		// Try each majority digit.
		for (int mD=0; mD<10; mD++) 
			res += go(1, mD, 0, 0, 0, num);
		
		// Now, just subtract out the contribution of co-majority digits.
		return res - numEq(num);
	}
	
	// if eq=1, then the # we are building is equal, so far to the target, if it's 0, it's less than.
	// majDigit is the majority digit.
	// numM is how many majority digits have been placed so far.
	// numR is how many other digits have been placed so far.
	// k is which digit we are placing. Note that numM + numR may not equal k due to leading 0s.
	// num is our target.
	public static long go(int eq, int majDigit, int numM, int numR, int k, String num) {
		
		// Easy base case.
		if (k == num.length()) return numM >= numR ? 1 : 0;
		
		// Speed up our recursion by storing old answers.
		String code = eq+","+majDigit+","+numM+","+numR+","+k;
		if (memo.containsKey(code)) return memo.get(code);
		
		long res = 0;
		
		// Place a zero first meaning our number has fewer digits.
		if (numM == 0 && numR == 0) res += go(0, majDigit, numM, numR, k+1, num);
		
		// Try each digit.
		for (int digit=0; digit<10; digit++) {
			
			// Can't place a 0 first.
			if (numM == 0 && numR == 0 && digit == 0) continue;
			
			// Just precomp these.
			int newNumM = digit == majDigit ? numM+1 : numM;
			int newNumR = digit != majDigit ? numR+1 : numR;
			
			// Check equality case, if it is, we can stop.
			if (eq==1 && digit == num.charAt(k)-'0') {
				res += go(1, majDigit, newNumM, newNumR, k+1, num);
				break;
			}
			
			// Add in these cases with digit in location k.
			res += go(0, majDigit, newNumM, newNumR, k+1, num);
		}
		
		// Store and return.
		memo.put(code, res);
		return res;
	}
}