ll n,s;ll f(ll a,ll b){!b?s+=a<=n:f(a*10+b%10,b/10);}{rd(n);n/=1d9+1;rep(i,1,1d5)f(i,i),f(i,i/10);wt(s);}