f(n,t){return n?t=pow(10,t=log10(n)),f(n%t/10)*10-n/t*~t:0;}long n,x=1+1e9;main(m){scanf("%ld",&n);m=log10(n/=x);printf("%d",n=n/pow(10,-~m/2)-~(m%2*9)*pow(10,m/2)-2+(f(n)<=n));}