using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; namespace Solver { class Program { const int M = 1000000007; const double eps = 1e-9; static void Main() { var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var s2 = new sol2(); var s = Console.ReadLine(); if (s[0] == ' ' || s[s.Length - 1] == ' ') return; var a = s.Split().Select(long.Parse).ToArray(); sw.WriteLine(s2.run(a[0], a[1])); sw.Flush(); } } class sol1 { public int run(int a, int b) { var sb = new StringBuilder(); for (int i = a; i <= b; i++) sb.Append(i); var s = sb.ToString(); int 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 += l[n - i - 1]; if (s[i] == '1') { if (s[i + 1] == '2') { if (i + 2 == n) ret += long.Parse(s.Substring(0, i)) * l[n - i - 1] + 1; else ret += long.Parse(s.Substring(0, i)) * l[n - i - 1] + long.Parse(s.Substring(i + 2)) + 1; } else if (s[i + 1] > '2') ret += (long.Parse(s.Substring(0, i)) + 1) * l[n - i - 1]; else ret += long.Parse(s.Substring(0, i)) * l[n - i - 1]; } else if (s[i] > '1') ret += (long.Parse(s.Substring(0, i)) + 1) * l[n - i - 1]; else ret += long.Parse(s.Substring(0, i)) * l[n - i - 1]; } return ret; } } }