var
s: string; n,m: integer;
begin
readln(n);
if (n <= 9) then write(n)
else if (n <= 9 + 9) then begin s := inttostr(n - 9);
write(s + s); end
else if (n <= 9 + 9 + 90) then begin s := inttostr(n - 9 -9 + 10 -1); m:=s.Length-1; write(s + s[m:0:-1]); end
else if (n <= 9 + 9 + 90 + 90) then begin s := inttostr(n - 9 - 9 + 90 + 10 - 1); write(s + s[::-1]); end
else if (n <= 9 + 9 + 90 + 90 + 900) then begin s := inttostr(n - 9 - 9 - 90 - 90 + 100 - 1); m:=s.Length-1; write(s + s[m:0:-1]); end
else if (n <= 9 + 9 + 90 + 90 + 900 + 900) then begin s := inttostr(n - 9 - 9 - 90 - 90 - 900 + 100 - 1); write(s + s[::-1]); end
else if (n <= 9 + 9 + 90 + 90 + 900 + 900 + 9000) then begin s := inttostr(n - 9 - 9 - 90 - 90 - 900 - 900 + 1000 - 1); m:=s.Length-1; write(s + s[m:0:-1]); end
else if (n <= 9 + 9 + 90 + 90 + 900 + 900 + 9000 + 9000) then begin s := inttostr(n - 9 - 9 - 90 - 90 - 900 - 900 - 9000 + 1000 - 1 ); write(s + s[::-1]); end
else begin s := inttostr(n - 9 - 9 - 90 - 90 - 900 - 900 - 9000 - 9000 + 10000 - 1); m:=s.Length-1; write(s + s[m:0:-1]); end
end.