#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <utility>
#define int long long
using namespace std;
int dp[20][2][12], n;
string s;
int countNumbers(int idx, int tight, int last){
if(idx == n) {
return 1;
}
int &ans = dp[idx][tight][last];
if(ans != -1)
return ans;
ans = 0;
int limit = tight ? (s[idx] - '0') : 9;
if(last == 10){
for(int i = 0; i <= limit; i++){
ans += countNumbers(idx + 1, tight & (i == limit), i == 0 ? 10: i);
}
} else{
for(int i = 0; i <= limit; i++){
if(i != last)
ans += countNumbers(idx + 1, tight & (i == limit), i);
}
}
return ans;
}
int countNumbers(string low, string high) {
s = high;
n = s.size();
memset(dp, -1, sizeof(dp));
int ans = countNumbers(0, 1, 10); // 10 is flag for leading zero
s = low;
n = s.size();
memset(dp, -1, sizeof(dp));
ans = ans - countNumbers(0, 1, 10);
bool check_low = true;
for(int i = 1; i < low.size(); i++){
if(low[i] == low[i - 1])
check_low = false;
}
if(check_low){
ans++;
}
return ans;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
string low, high;
cin >> low >> high;
cout << countNumbers(low, high);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjYXNzZXJ0PgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPGRlcXVlPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8dW5vcmRlcmVkX21hcD4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHVub3JkZXJlZF9zZXQ+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDx1dGlsaXR5PiAgIAojZGVmaW5lIGludCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCgoKaW50IGRwWzIwXVsyXVsxMl0sIG47CnN0cmluZyBzOwoKICAgIAppbnQgY291bnROdW1iZXJzKGludCBpZHgsIGludCB0aWdodCwgaW50IGxhc3QpewogICAgaWYoaWR4ID09IG4pIHsKICAgICAgIHJldHVybiAxOwogICAgfQogICAgaW50ICZhbnMgPSBkcFtpZHhdW3RpZ2h0XVtsYXN0XTsKICAgIGlmKGFucyAhPSAtMSkKICAgICAgICByZXR1cm4gYW5zOwoKICAgIGFucyA9IDA7CgogICAgaW50IGxpbWl0ID0gdGlnaHQgPyAoc1tpZHhdIC0gJzAnKSA6IDk7CiAgICAKICAgIGlmKGxhc3QgPT0gMTApewogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPD0gbGltaXQ7IGkrKyl7CiAgICAgICAgICAgYW5zICs9IGNvdW50TnVtYmVycyhpZHggKyAxLCB0aWdodCAmIChpID09IGxpbWl0KSwgaSA9PSAwID8gMTA6IGkpOwogICAgICAgIH0KICAgIH0gZWxzZXsKICAgIAlmb3IoaW50IGkgPSAwOyBpIDw9IGxpbWl0OyBpKyspewogICAgCSAgIGlmKGkgIT0gbGFzdCkKICAgIAkJIGFucyArPSBjb3VudE51bWJlcnMoaWR4ICsgMSwgdGlnaHQgJiAoaSA9PSBsaW1pdCksIGkpOwogICAgCX0KICAgIH0KICAgIAogICAgcmV0dXJuIGFuczsKfQogaW50IGNvdW50TnVtYmVycyhzdHJpbmcgbG93LCBzdHJpbmcgaGlnaCkgewogICAgICAgICBzID0gaGlnaDsKICAgICAgICAgbiA9IHMuc2l6ZSgpOwogICAgICAgICBtZW1zZXQoZHAsIC0xLCBzaXplb2YoZHApKTsKICAgICAgICAgaW50IGFucyA9IGNvdW50TnVtYmVycygwLCAxLCAxMCk7IC8vIDEwIGlzIGZsYWcgZm9yIGxlYWRpbmcgemVybwoKICAgICAgICAgcyA9IGxvdzsKICAgICAgICAgbiA9IHMuc2l6ZSgpOwogICAgICAgICBtZW1zZXQoZHAsIC0xLCBzaXplb2YoZHApKTsKICAgICAgICAgYW5zID0gYW5zIC0gY291bnROdW1iZXJzKDAsIDEsIDEwKTsKCiAgICAgICAgIGJvb2wgY2hlY2tfbG93ID0gdHJ1ZTsKICAgICAgICAgZm9yKGludCBpID0gMTsgaSA8IGxvdy5zaXplKCk7IGkrKyl7CiAgICAgICAgICAgICBpZihsb3dbaV0gPT0gbG93W2kgLSAxXSkKICAgICAgICAgICAgICAgIGNoZWNrX2xvdyA9IGZhbHNlOwogICAgICAgICB9CiAgICAgICAgIGlmKGNoZWNrX2xvdyl7CiAgICAgICAgICAgICBhbnMrKzsKICAgICAgICAgfQogICAgICAgICByZXR1cm4gYW5zOwp9CgppbnQzMl90IG1haW4oKSB7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CiAgI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgIGZyZW9wZW4oImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKICAjZW5kaWYKICAKICBzdHJpbmcgbG93LCBoaWdoOwogIGNpbiA+PiBsb3cgPj4gaGlnaDsKCiAgCiAgY291dCA8PCBjb3VudE51bWJlcnMobG93LCBoaWdoKTsKCiByZXR1cm4gMDsKfQ==