rt,不知道为啥10pts
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(w, n) for (int i = w; i <= n; i++)
int dp[20][10][2][2];
ll len, A[20];
ll DP(ll pos, ll las, int lim, int ctrl_zero)
{
if (pos == 0)
return 1;
if (dp[pos][las][lim][ctrl_zero] != 1)
return dp[pos][las][lim][ctrl_zero];
ll ans = 0;
FOR(0, (lim ? A[pos] : 9))
{
if (!ctrl_zero && abs(las - i) < 2)
continue;
ans += DP(pos - 1, i, lim && i == A[pos], ctrl_zero && i == 0);
}
dp[pos][las][lim][ctrl_zero] = ans;
return dp[pos][las][lim][ctrl_zero];
}
ll fl(ll n)
{
len = 0;
while (n)
{
A[++len] = n % 10;
n /= 10;
}
memset(dp, -1, sizeof(dp));
return DP(len, 0, 1, 1);
}
int main()
{
ios::sync_with_stdio(false);
int l, r;
cin >> l >> r;
cout << fl(r) - fl(l - 1) << '\n';
}