#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define vl vector<ll>
#define vi vector<int>
using namespace std;
 
ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve(){
	ll n;cin>>n;
	ll len=0,t=n;
	vector<ll> v;
	while(t){
		len++;
		v.pb(t%10);t/=10;
	}
	reverse(all(v));
	ll ans=0;
	for(int i=2;i<=len;i+=2){
		ll cur=1;
		if(i!=len){
			for(int j=0;j<i/2;j++){
			if(j==0) cur*=9;
			else cur*=10;
		  }
		}else{
			for(int j=0;j<i/2;j++){
			if(j==0) cur*=(v[j]-1);
			else cur*=10;
		  }
		  ll end=1;
		  for(int k=1;k<i/2;k++){
		  	end*=v[k];
		  	for(int l=k+1;l<i/2;l++) end*=10;
		  	cur+=end;
		  	end=1;
		  }
		  ll num=0;
		  int j=len;
		  for(int l=1;l<=2;l++){
		  	for(int k=0;k<i/2;k++){
		  		
		  		num+=v[k]*pow(10,j-1);j--;
		   }
		  }
		  if(num<=n) cur++;
		  
		  
		}
		
		ans+=cur;	
	}
	cout<<ans<<endl;
		
}

int main(){

		fast;
	    int T;
	    T=1;
	    //cin>>T;
	  	while(T--){
	  		//for(int i=1;i<=T;i++){
	  			//cout<<"Case #"<<i<<": ";
	 			solve();
	 		 }
	 return 0;
	 
}
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
long long n;
long long x1;
int ans = 1;
string s;
 
 
int main()
{
    cin >> n;

    long long x = 1;
    int count = 0;
    long long x1 =0;

    while(x1<=n){
        s = to_string(x);
        x1 = stoll(s+s);
        x++;
    }

    cout << x-2;
 
         return 0;
}