#include <bits/stdc++.h>
using namespace std;
#ifdef loc
#include "loc_debug.h"
#else
#define pr(...)
#define pra(a,n)
#define praa(a,n,m)
#define prl()
#endif
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i, s, n) for(int i = s; i <= n; ++i)
#define rev(i, n, s) for(int i = n; i >= s; --i)
#define fore(x, a) for(auto &&x : a)
#define fill(a, x) memset((a), (x), sizeof(a))
#define tcase int __t; cin >> __t; rep(tc, 1, __t)
#define F first
#define S second
#define gc getchar
const int mod = 1000000007;
#define _ %mod
const int N = 100005;
vector<vector<int>> a;
bool canp[N];
bool can(vector<int> b) {
int sum = 0;
fore(x, b) {
sum += x;
}
if(sum & 1) {
return 0;
}
vector<bool> v(sum / 2 + 1, 0);
v[0] = 1;
fore(x, b) {
rev(i, sum / 2, x) {
v[i] = v[i] || v[i - x];
}
}
return v[sum / 2];
}
void go(int sum, vector<int> b) {
a.eb(b);
if(sz(b) >= 10) {
return;
}
rep(i, b.empty() ? 1 : b.back(), 9) {
if(sum + i > 84) {
break;
}
vector<int> c(b);
c.eb(i);
go(sum + i, c);
}
}
int dp[11][2][N];
int b[11];
map<ll, int> lb;
int ns[N][10];
int dodp(int p, bool c, int w) {
if(p == -1) {
return canp[w];
}
int &res = dp[p][c][w];
if(res == -1) {
res = 0;
rep(i, 0, 9) {
if(c || (i <= b[p])) {
res += dodp(p - 1, c || (i < b[p]), ns[w][i]);
}
}
}
return res;
}
int count(ll x) {
fill(dp, -1);
rep(i, 0, 10) {
b[i] = int(x % 10);
x /= 10;
}
int res = dodp(10, 0, 0);
return res;
}
int main() {
fast_io;
go(0, vector<int>());
sort(all(a));
rep(i, 0, sz(a) - 1) {
canp[i] = can(a[i]);
}
rev(i, sz(a) - 1, 0) {
ll cur = 0;
rep(j, 0, sz(a[i]) - 1) {
cur = 10 * cur + a[i][j];
}
lb[cur] = i;
}
rep(i, 0, sz(a) - 1) {
rep(k, 0, 9) {
ll cur = 0;
bool done = 0;
if(k == 0) {
done = 1;
}
rep(j, 0, sz(a[i]) - 1) {
cur *= 10;
if((!done) && k <= a[i][j]) {
cur += k;
cur *= 10;
done = 1;
}
cur += a[i][j];
}
if(!done) {
cur = 10 * cur + k;
}
if(lb.find(cur) != lb.end()) {
ns[i][k] = lb[cur];
}
}
}
while(true) {
ll l, r;
cin >> l >> r;
if(l == 0 || r == 0) {
break;
}
cout << count(r) - count(l - 1) << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojaWZkZWYgbG9jCiAgICAjaW5jbHVkZSAibG9jX2RlYnVnLmgiCiNlbHNlCiAgICAjZGVmaW5lIHByKC4uLikKICAgICNkZWZpbmUgcHJhKGEsbikKICAgICNkZWZpbmUgcHJhYShhLG4sbSkKICAgICNkZWZpbmUgcHJsKCkKI2VuZGlmCgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBsb25nIGRvdWJsZSBsZDsKI2RlZmluZSBmYXN0X2lvIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApCiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgZWIgZW1wbGFjZV9iYWNrCiNkZWZpbmUgYWxsKHgpICh4KS5iZWdpbigpLCAoeCkuZW5kKCkKI2RlZmluZSBzeihhKSBpbnQoYS5zaXplKCkpCiNkZWZpbmUgcmVwKGksIHMsIG4pICBmb3IoaW50IGkgPSBzOyBpIDw9IG47ICsraSkKI2RlZmluZSByZXYoaSwgbiwgcykgIGZvcihpbnQgaSA9IG47IGkgPj0gczsgLS1pKQojZGVmaW5lIGZvcmUoeCwgYSkgZm9yKGF1dG8gJiZ4IDogY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yXVtOXTsKaW50IGJbMTFdOwptYXA8bGwsIGludD4gbGI7CmludCBuc1tOXVsxMF07CgppbnQgZG9kcChpbnQgcCwgYm9vbCBjLCBpbnQgdykgewogICAgaWYocCA9PSAtMSkgewogICAgICAgIHJldHVybiBjYW5wW3ddOwogICAgfQogICAgaW50ICZyZXMgPSBkcFtwXVtjXVt3XTsKICAgIGlmKHJlcyA9PSAtMSkgewogICAgICAgIHJlcyA9IDA7CiAgICAgICAgcmVwKGksIDAsIDkpIHsKICAgICAgICAgICAgaWYoYyB8fCAoaSA8PSBiW3BdKSkgewogICAgICAgICAgICAgICAgcmVzICs9IGRvZHAocCAtIDEsIGMgfHwgKGkgPCBiW3BdKSwgbnNbd11baV0pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIHJlczsKfQoKaW50IGNvdW50KGxsIHgpIHsKICAgIGZpbGwoZHAsIC0xKTsKICAgIHJlcChpLCAwLCAxMCkgewogICAgICAgIGJbaV0gPSBpbnQoeCAlIDEwKTsKICAgICAgICB4IC89IDEwOwogICAgfQogICAgaW50IHJlcyA9IGRvZHAoMTAsIDAsIDApOwogICAgcmV0dXJuIHJlczsKfQoKaW50IG1haW4oKSB7CiAgICBmYXN0X2lvOwogICAgZ28oMCwgdmVjdG9yPGludD4oKSk7CiAgICBzb3J0KGFsbChhKSk7CiAgICByZXAoaSwgMCwgc3ooYSkgLSAxKSB7CiAgICAgICAgY2FucFtpXSA9IGNhbihhW2ldKTsKICAgIH0KICAgIHJldihpLCBzeihhKSAtIDEsIDApIHsKICAgICAgICBsbCBjdXIgPSAwOwogICAgICAgIHJlcChqLCAwLCBzeihhW2ldKSAtIDEpIHsKICAgICAgICAgICAgY3VyID0gMTAgKiBjdXIgKyBhW2ldW2pdOwogICAgICAgIH0KICAgICAgICBsYltjdXJdID0gaTsKICAgIH0KICAgIHJlcChpLCAwLCBzeihhKSAtIDEpIHsKICAgICAgICByZXAoaywgMCwgOSkgewogICAgICAgICAgICBsbCBjdXIgPSAwOwogICAgICAgICAgICBib29sIGRvbmUgPSAwOwogICAgICAgICAgICBpZihrID09IDApIHsKICAgICAgICAgICAgICAgIGRvbmUgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJlcChqLCAwLCBzeihhW2ldKSAtIDEpIHsKICAgICAgICAgICAgICAgIGN1ciAqPSAxMDsKICAgICAgICAgICAgICAgIGlmKCghZG9uZSkgJiYgayA8PSBhW2ldW2pdKSB7CiAgICAgICAgICAgICAgICAgICAgY3VyICs9IGs7CiAgICAgICAgICAgICAgICAgICAgY3VyICo9IDEwOwogICAgICAgICAgICAgICAgICAgIGRvbmUgPSAxOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY3VyICs9IGFbaV1bal07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoIWRvbmUpIHsKICAgICAgICAgICAgICAgIGN1ciA9IDEwICogY3VyICsgazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZihsYi5maW5kKGN1cikgIT0gbGIuZW5kKCkpIHsKICAgICAgICAgICAgICAgIG5zW2ldW2tdID0gbGJbY3VyXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHdoaWxlKHRydWUpIHsKICAgICAgICBsbCBsLCByOwogICAgICAgIGNpbiA+PiBsID4+IHI7CiAgICAgICAgaWYobCA9PSAwIHx8IHIgPT0gMCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY291dCA8PCBjb3VudChyKSAgLSBjb3VudChsIC0gMSkgPDwgZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==