#include<iostream>
#include<string>
using namespace std;

int main(){
    long long N;
    cin >> N;
    int ans = 0;
    for(long long i=1; ; i++){
        if(stoll(to_string(i)+to_string(i))<=N) ans += 1;
        else break;
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	/*long long a,b,c;
	if(a==0 or a==1 or a==5 or a==6){
		cout<<a<<"\n";
	}else{
		
	
	
	}*/
	string memo;
	cin>>memo;
		long long th=memo.size();
	map<char,long long> save;
	long long sum=th,ans=0,con,k,i;

	for(i=th-1,con=0;i>=0;i--,con++){
		save[memo[i]]+=1;
		char aux=memo[i];
		if(i>0){
			long long lol=con,j=i;
			for(k=0;memo[i-1]==aux && i>=0;i--,k++){
				con+=1;
				if(k==0){
				ans+=con-save[aux];		
				//cout<<con<<" "<<save[aux]<<" "<<i<<"\n";		
				}
				save[aux]+=1;
			}
			if(k>0){
				save.clear();
				save[aux]=con+1;
			}
			
		}
	}
	cout<<ans<<"\n";
	

return 0;
}
