#include #include #include using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,n,0) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 100000000 typedef long long ll; ll power(ll x, ll n) { return n == 0 ? 1 : x * power(x,n-1); } ll count(string a) { int i, j; ll ret = 0; ll dp[2][3][14] {}; dp[0][0][0] = 1; rep (i,a.size()) { int n = a[i] - '0'; rep (j,10) { if (j == 2) { dp[0][2][i+1] += n == j ? dp[0][1][i] : 0; dp[1][2][i+1] += dp[1][1][i] + (j < n ? dp[0][1][i] : 0); } else if (j == 1) { dp[0][1][i+1] += n == j ? dp[0][0][i] : 0; dp[1][1][i+1] += dp[1][0][i] + (j < n ? dp[0][0][i] : 0); } dp[0][0][i+1] += n == j ? dp[0][0][i] : 0; dp[1][0][i+1] += dp[1][0][i] + (j < n ? dp[0][0][i] : 0); dp[0][2][i+1] += n == j ? dp[0][2][i] : 0; dp[1][2][i+1] += dp[1][2][i] + (j < n ? dp[0][2][i] : 0); } } ret = dp[0][2][a.size()] + dp[1][2][a.size()]; rep (i,(int)a.size()-2) ret += power(10,i); if (a.size() > 1 && a[0] > '2') ret += power(10,a.size()-2); else if (a[0] == '2') { int n = 0; REP (i,1,a.size()-1) n = n * 10 + a[i] - '0'; if (a.back() >= '2') n++; ret += n; } return ret; } int main() { ll num; string a, b; cin >> num >> b; a = to_string(num-1); cout << count(b) - count(a) << endl; return 0; }