import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } static long N; static long FACTOR = 1_000_000_000 + 1; static long[] pow10 = new long[19]; void run() { pow10[0] = 1; for (int i = 1; i < pow10.length; ++i) pow10[i] = pow10[i - 1] * 10; Scanner sc = new Scanner(System.in); N = sc.nextLong(); if (N < FACTOR) { System.out.println(0); return; } long ans = 0; for (long v = 1; v < pow10[6]; ++v) { long d = 0; int s = 0; int t = 2 * String.valueOf(v).length() - 1; while (t - s > 0) { long digi = (v % pow10[s + 1] / pow10[s]); d += digi * (pow10[s] + pow10[t]); ++s; --t; } if (d >= pow10[9]) continue; d *= FACTOR; if (d <= N) { ++ans; } } for (int i = 1; i <= 9; ++i) { if (i * FACTOR <= N) ++ans; } System.out.println(ans); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }