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