import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons, std.typetuple; import core.bitop, std.datetime; void main(){ auto N = readln.chomp.to!ulong; ulong a = 10^^9 + 1; ulong M = N / a; ulong ans; //stderr.writeln(M); ulong[10] k = [0, 9, 9, 90, 90, 900, 900, 9000, 9000, 90000]; //stderr.writeln(k); int d = 1; while(10^^d <= M){ ans += k[d]; ++d; } --d; //stderr.writeln(d); int uni = d > 0 ? 10^^d + 1 : 1; int e = 1; while(uni*e <= M){ //stderr.writeln(uni*e); ans += max(1, k[max(0, d - 2)]); ++e; } --e; //stderr.writeln(e); int f = 1; while(uni*e + f*10 <= M){ if(is_kaibun(f)){ ++ans; } ++f; } writeln(ans); } bool is_kaibun(int m){ int rev, rem, tmp; tmp = m; while(tmp != 0){ rem = tmp % 10; rev = rev * 10 + rem; tmp /= 10; } if(m == rev) return true; else return false; } void readVars(T...)(auto ref T args){ auto line = readln.split; foreach(ref arg ; args){ arg = line.front.to!(typeof(arg)); line.popFront; } if(!line.empty){ throw new Exception("args num < input num"); } }