#include<iostream> #include<cstdio> usingnamespace std; int f[15][15]; intabs(int x){return x >= 0 ? x : -x;} intcalc(int x){ int len = 0, n[15], t = x, ret = 0; while (t) n[++len] = t%10, t /= 10; for (int i = 1; i < len; i++) for (int j = 1; j <= 9; j++) ret += f[i][j]; for (int i = len; i; i--) { for (int j = (i == len ? 1 : 0); j < n[i]; j++) if (i == len || abs(j-n[i+1]) >= 2) ret += f[i][j]; if (i < len && abs(n[i+1]-n[i]) < 2) break; } return ret; } intmain(){ for (int i = 0; i <= 9; i++) f[1][i] = 1; for (int i = 1; i <= 10; i++) for (int j = 0; j <= 9; j++) { for (int k = 0; k <= j-2; k++) f[i+1][k] += f[i][j]; for (int k = j+2; k <= 9; k++) f[i+1][k] += f[i][j]; } int l, r; scanf("%d%d", &l, &r); printf("%d", calc(r+1)-calc(l)); return0; }