#include "bits/stdc++.h"
using namespace std;

#define int long long
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve() {
    int n;
    cin >> n;

    int ans = 0;

    f(i,1,1e6+1){
        int len = log10(i) + 1;
        int cur = 1;
        f(j,0,len) cur*=10;
        if(cur*i + i <= n){
            ans++;
        }
    }
    cout << ans << "\n";
}

int32_t main() {
    fast;
    int t = 1;
    // cin >> t;
    while (t--)  solve();
}
#include<bits/stdc++.h>
using namespace std;
int main() {
long long int n,count=0;
cin>>n;
for(int i=1;i<=1000000;i++){
    string s=to_string(i);
    string r=s+s;
  long long   int res=stoll(r);
    count++;
    if(res>n){
        break;
    }
}
cout<<count-1<<endl;
	return 0;
}