inlineintread() { ints(0), w(1); char ch = getchar(); while (ch < '0' || ch > '9') {if (ch == '-') w = -1; ch = getchar();} while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; }
inlinevoidput(int x) { if (! x) putchar('0'); if (x < 0) putchar('-'), x = -x; intnum(0); char c[66]; while (x) c[++ num] = x % 10 + 48, x /= 10; while (num) putchar(c[num --]); return (void)(putchar('\n')); }
int n, m, cnt; int num[N], f[N][N]; /* pos 当前枚举的哪一位 pre 上一位是谁 flag 上一位是否达到了限制,换言之,前边搜到的数字,是否和原数字匹配了 lim 是否有前导零 */ inlineintdfs(int pos, int pre, int flag, int lim) { if (! pos) return1; if (! flag && f[pos][pre] != -1 && !lim) return f[pos][pre]; int i, nex, res(0); nex = flag ? num[pos] : 9; for (i = 0; i <= nex; ++ i) { int delta = abs(pre - i); if (delta < 2 && ! lim) continue; if (i == nex && flag) res += dfs(pos - 1, i, 1, 0); else res += (i || ! lim) ? dfs(pos - 1, i, 0, 0) : dfs(pos - 1, i, 0, 1); } if (! flag && ! lim) f[pos][pre] = res; return res; }
inlineintcalc(int x) { memset (f, -1, sizeof f), cnt = 0; while (x) num[++ cnt] = x % 10, x /= 10; returndfs(cnt, 0, 1, 1); }
signedmain() { n = read(), m = read(); put(calc(m) - calc(n - 1)); return0; }