import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; bool is_kaibun(string s) { int n = s.length.to!int; foreach (i; 0..n/2) { if (s[i] != s[n-i-1]) return false; } return true; } void main() { long N = readln.chomp.to!long; long M = 10^^9; long a = N / M; if (a == 0) { writeln(0); return; } string s = a.to!string; long b = s.length; long ans = 0; foreach (i; 1..b+1) { if (i == b) { ans += 10 ^^ (i/2+i%2-1) * (s[0].to!string.to!long-1); } else { if (i == 1) ans += 9; else ans += 10^^(i/2+i%2); } } long keta = b-1; keta = keta/2+keta%2; long base = a - (a % 10^^(b-1)); foreach (i; 0..10^^keta) { long nnn; nnn = base + i; if (!(is_kaibun(nnn.to!string))) continue; long mmm = nnn*10^^9 + nnn; if (mmm <= N) ans++; } ans.writeln; }