import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(long[]), a = rd[0]-1, b = rd[1]; auto ai = digits(a), bi = digits(b); auto ra = calc(ai) + (a >= 2 ? 1 : 0); auto rb = calc(bi) + (b >= 2 ? 1 : 0); auto r = rb - ra; if (a <= 1 || a > 1 && ai[$-1] == 1 && ai[0] == 2) --r; writeln(r); } auto digits(long n) { int[] r; for (; n > 0; n /= 10) r ~= n % 10; r.reverse(); return r; } auto calc(int[] a) { auto n = a.length.to!int; auto dp1 = new long[][][][](n+1, 2, 2, 7); dp1[0][0][0][0] = 1; foreach (i; 0..n) foreach (j; 0..2) foreach (k; 0..2) foreach (l; 0..7) { auto dm = j ? 9 : a[i]; foreach (d; 0..dm+1) { if (d == 2 && k == 1 && l < 6) dp1[i+1][j || d