#include<bits/stdc++.h>
using namespace std ;
#define int long long int
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    int x, cnt = 0;
    for(int i = 1; i < 1e7; i++){
        x = i * pow(10, to_string(i).size()) + i;
        if(x > n) break;
        cnt++;
    }
    cout << cnt << "\n";
    return 0;
}
#include <iostream>
#include <string>

long long kaijou_ten(int sisuu) {
    long long ret = 1;
    for ( int i = 0; i < sisuu; ++i ) {
        ret *= 10;
    }
    return ret;
}

int main() {
    
    std::string str;
    std::cin >> str;

    long long n = str.size();
    //std::cout << n << std::endl;
    long long ans = 0;
    if ( n % 2  == 1 ) {
        for ( int i = 1; i <= (n / 2); ++i ) {
            ans += 9 * kaijou_ten(i-1); 
        }
    }
    else {
        for ( int i = 1; i < (n / 2); ++i ) {
            ans += 9 * kaijou_ten(i-1);
        }
        std::string strL;
        std::string strR;
        /*for ( int i = 1; i <= (n / 2); ++i ) {
            strL[i-1] = str[i-1];
            strR[n/2 + i-1] = str[n/2 + i-1];
        }
        */
        strL = str.substr(0,n/2);
        strR = str.substr(n/2,n/2);
        long long lval = std::stoll(strL);
        long long rval = std::stoll(strR);
        //std::cout << strL << " " << strR << std::endl;
        //std::cout << lval << " " << rval << std::endl;
        
        if ( lval > rval ) {
            ans += lval - kaijou_ten(n/2 - 1);
        }
        else {
            ans += lval - kaijou_ten(n/2 - 1) + 1;
        }
        
    }

    std::cout << ans << std::endl;
    return 0;
}