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 < 100_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() <= 5) { int m = tmp.length(); if (m * 2 >= 6) { StringBuilder tmp2 = new StringBuilder(); for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(m - 1 - j)); } if (m == 5) { tmp2.deleteCharAt(m - 1); } for (int j = 0; j < m; j++) { tmp2.append(tmp.charAt(j)); } long ltmp = Long.parseLong(tmp2.toString()); if (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); } } }