#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
int dp[20][12][12][2][2]; // (ind, prv, cur, tight, started)
void solve() {
int l, r; cin>>l>>r;
string s;
function<int(int, int, int, int, int)> magic = [&] (int ind, int prv, int cur, int tight, int started) {
if(ind == s.size()) return 1LL;
int &ans = dp[ind][prv][cur][tight][started];
if(~ans) return ans;
ans = 0;
int mx = tight ? s[ind] - '0' : 9;
for(int i = 0; i <= mx; i++) {
if(i == 0 && !started) {
ans += magic(ind + 1, prv, cur, tight & (i == mx), 0);
} else if(i != prv && i != cur) {
ans += magic(ind + 1, cur, i, tight & (i == mx), 1);
}
}
return ans;
};
auto cnt = [&] (int n) {
s = to_string(n);
int ans = 0;
memset(dp, -1, sizeof dp);
ans += magic(0, 10, 10, 1, 0);
return ans;
};
cout<<cnt(r) - cnt(l - 1)<<endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1, c = 1; //cin>>t;
while(t--) {
// cerr<<"Case "<<c++<<": \n";
solve();
}
}
/*
i/p:
o/p:
*/