#include using namespace std; using ll=long long; #define int ll #define FOR(i,a,b) for(int i=int(a);i; using vi=vector; using ld=long double; template ostream& operator<<(ostream& os,const pair& p){ os<<"("< ostream& operator <<(ostream& os,const vector& v){ os<<"["; REP(i,(int)v.size()){ if(i)os<<","; os< void chmax(T& a,U b){ if(a void chmin(T& a,U b){ if(a>b) a=b; } template T Sq(const T& t){ return t*t; } const int inf=LLONG_MAX/3; int Kyuri(int x){ int res=0; while(x){ res++; x/=10; } return res; } int reverse(int x){ vi d; while(x){ d.PB(x%10); x/=10; } int res=0; for(auto v:d){ res*=10; res+=v; } return res; } int pow10(int x){ int res=1; while(x--)res*=10; return res; } int check(int i,int h,int x,int d){ int t=i*pow10(d-h); if(h>d-h)i/=10; return t+reverse(i)<=x; } int Wafrelka(int x){ if(x<=0)return 0; int d=Kyuri(x); int h=(d+1)/2,g=pow10(h); int res=0; int l=pow10(h-1)-1,r=g; while(r-l>1){ const int mid=(l+r)/2; if(check(mid,h,x,d)) l=mid; else r=mid; } res+=l-(pow10(h-1)-1); FOR(e,1,d) res+=pow10((e+1)/2)-pow10((e+1)/2-1); return res; } signed main(){ int n=read(); int x=n/1000000000; if(x*1000000000+reverse(x)>n)x--; cout<