#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod=1e9+7;
const int maxV=2e7+1;
const ll inf=1e18+1;
int main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n;
    cin>>n;
    ll p10=10;
    int cnt=0;
    for(int i=1;i<1e6;i++){
        if(i==10 || i==100 || i==1000 || i==10000 || i==100000){
            p10*=10;
        }
        if(i*p10+i<=n){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
}
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){
        cout << i - 1 << endl;
        return 0;
    }
}
