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 ra = calc(a); auto rb = calc(b); auto r = rb - ra, ai = digits(a); if (a == 1 || a > 0 && ai[0] == 2 && ai[$-1] == 1) --r; writeln(r); } auto digits(long n) { int[] r; for (; n > 0; n /= 10) r ~= n % 10; r.reverse(); return r; } auto calc(long a) { auto ai = digits(a), n = ai.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 : ai[i]; foreach (d; 0..dm+1) { if (d == 2 && k == 1 && l < 6) dp1[i+1][j || d