import java.io.*; import java.util.*; public class Main_yukicoder491 { private static Scanner sc; private static Printer pr; private static void solve() { long n = sc.nextLong(); long t = 1_000_000_001; int ret = 0; for (int i = 1; i < 10_000; i++) { if (i % 10 == 0) { continue; } StringBuilder tmp = new StringBuilder(); tmp.append(i); if (t * i <= n) { if (isPalindrome(tmp)) { ret++; } } while (tmp.length() <= 4) { int m = tmp.length(); StringBuilder tmp2 = new StringBuilder(); for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(m - 1 - j)); } for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(j)); } long ltmp = Long.parseLong(tmp2.toString()); if (ltmp > 9999 && ltmp < 1_000_000_000 && t * ltmp <= n) { ret++; } for (int c = 0; c < 10; c++) { tmp2 = new StringBuilder(); for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(m - 1 - j)); } tmp2.append((char)('0' + c)); for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(j)); } ltmp = Long.parseLong(tmp2.toString()); if (ltmp > 9999 && ltmp < 1_000_000_000 && t * ltmp <= n) { ret++; } } tmp.insert(0, '0'); } } pr.println(ret); } private static boolean isPalindrome(StringBuilder str) { int n = str.length(); boolean flag = true; for (int i = 0; i < n / 2; i++) { if (str.charAt(i) != str.charAt(n - 1 - i)) { flag = false; break; } } return flag; } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }