using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; namespace Solver { class Program { static void Main() { var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var s2 = new sol2(); var a = Console.ReadLine().Split().Select(long.Parse).ToArray(); sw.WriteLine(s2.run(a[0], a[1])); sw.Flush(); } } // 愚直数え上げ解法 class sol1 { public long run(long a, long b) { var sb = new StringBuilder(); for (var i = a; i <= b; i++) sb.Append(i); // StringBuilder壊れる~~~ var s = sb.ToString(); long ans = 0; for (int i = 0; i < s.Length - 1; i++) if (s[i] == '1' && s[i + 1] == '2') ++ans; return ans; } } // 想定解法 class sol2 { public long run(long a, long b) { var s = (a - 1).ToString(); if (s[s.Length - 1] == '1' && a.ToString()[0] == '2') return count(b) - count(a - 1) - 1; return count(b) - count(a - 1); } long count(long a) { if (a < 2) return 0; if (a < 12) return 1; var s = a.ToString(); int n = s.Length; long ret = 1; var l = new long[n]; l[1] = 1; for (int i = 1; i < n - 1; i++) l[i + 1] = l[i] * 10; for (int i = 0; i < n - 1; i++) { if (i == 0) { if (s[0] == '1') { if (s[1] == '2') { if (n == 2) return 2; ret += long.Parse(s.Substring(2)) + 1; } else if (s[1] > '2') ret += l[n - 1]; } else if (s[0] == '2') { if (s[n - 1] > '1') { if (n == 2) return 3; ret += long.Parse(s.Substring(1, n - 2)) + 1; } else { if (n == 2) return 2; ret += long.Parse(s.Substring(1, n - 2)); } ret += l[n - 1]; } else ret += l[n - 1] * 2; continue; } ret += (long.Parse(s.Substring(0, i)) + 1) * l[n - i - 1]; if (s[i] == '1') { if (s[i + 1] == '2') { ++ret; if (i + 2 < n) ret += long.Parse(s.Substring(i + 2)); } else if (s[i + 1] > '2') ret += l[n - i - 1]; } else if (s[i] > '1') ret += l[n - i - 1]; } return ret; } } }