#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

typedef unsigned long long ull;

ull a, b;
ull cur[2][2][2][60000];
//ull old[2][2][1 << 10][1 << 10];
//    follow num? , count zero? , has digit, parity digit

int pow3[16];

inline void add()
{
	pow3[0] = 1;
	for (int i=1; i < 13; ++i)
		pow3[i] = pow3[i-1]*3;
}

inline int addToMask(int mask, int pos)
{
	int ans = mask;

	int bit = mask % pow3[pos+1];
	bit /= pow3[pos];

	if (!bit) ans += pow3[pos];
	if (bit == 1) ans += pow3[pos];
	if (bit == 2) ans -= pow3[pos];


	return ans;
}

inline int has(int mask, int pos)
{
	int bit = mask % pow3[pos+1];
	bit /= pow3[pos];

	return bit >= 1;
}

inline int getParity(int mask, int pos)
{
	int bit = mask % pow3[pos+1];
	bit /= pow3[pos];

	return (bit == 1);
}

inline ull solve(ull x)
{
	vector<int> dig; dig.clear();
	if (x == 0) return 1;

	while (x)
	{
		dig.push_back(x % 10LL);
		x /= 10LL;
	}
	reverse(dig.begin(), dig.end());
	int len = dig.size();

	//printf("len = %d\n", len);

	memset(cur, 0, sizeof(cur));
	cur[1][0][1][0] = 1LL;
	int to, nCntZero, nMask3, ok, maskPar;
	for (int size=0; size < len; ++size)
	{
		int blah = size&1;
		memset(cur[blah], 0, sizeof(cur[blah]));
		for (int mask3=0; mask3 < pow3[10]; ++mask3)
			for (int cntZero=0; cntZero < 2; ++cntZero)
				for (int follow=0; follow < 2; ++follow)
				{
					if (!cur[!blah][cntZero][follow][mask3])
						continue;
					int to = follow? dig[size] : 9;

					//printf("currently with %d %d %d %d -> %llu\n", cntZero, follow, maskHas, maskPar, old[cntZero][follow][maskHas][maskPar]);
					for (int next=0; next <= to; ++next)
					{
						nCntZero  = cntZero | (next > 0);
						nMask3 = addToMask(mask3, next);
						// adding to mask new
						if (!nCntZero)
							nMask3 = mask3;
						//printf("new -> %d %d \n", nMaskHas, nMaskPar);
						cur[blah][nCntZero][follow & (next == to)][nMask3] +=
							cur[!blah][cntZero][follow][mask3];
					}
				}
	}

	ull ans = 0LL;
	int blah = len&1;
	for (int mask3=0; mask3 < pow3[10]; ++mask3)
	{
		if (!cur[!blah][1][0][mask3]) continue;

		ok = 1;
		for (int d=0; d < 10; ++d)
			if (has(mask3, d))
				if ((d + getParity(mask3, d)) % 2 == 0)
				{
					ok = 0;
					break;
				}

		if (ok)
			ans += cur[!blah][1][0][mask3];
			//printf("aaand ans += %llu from %d %d %d %d\n", cur[1][0][maskHas][maskPar], 1, 0, maskHas, maskPar);
	}

	return ans;
}

inline void read()
{
	scanf("%llu%llu", &a, &b);
}

int main()
{
	read();
	add();
	printf("%llu\n", solve(b+1) - solve(a));
	return 0;
}
