long n,x=1e9+1,s;f(a,b){return b?f(a*10+b%10,b/10):a;}main(i){scanf("%ld",&n);for(n/=x;99999/i;s+=f(i++,i/10)<=n)s+=9999/i&&n/f(i,i);printf("%d",s);}