#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

#define ll long long

vector<ll> vec;

void solve(){
    for(char i = '1';i<='9';i++){
        string temp = "";
        temp += i;
        temp += temp;
        vec.push_back(stoll(temp));
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            string temp = "";
            temp += i;
            temp += j;
            temp += temp;
            vec.push_back(stoll(temp));
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                string temp = "";
                temp += i;
                temp += j;
                temp += k;
                temp += temp;
                vec.push_back(stoll(temp));
            }
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                for(char l = '0';l<='9';l++){
                    string temp = "";
                    temp += i;
                    temp += j;
                    temp += k;
                    temp += l;
                    temp += temp;
                    vec.push_back(stoll(temp));
                }
            }
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                for(char l = '0';l<='9';l++){
                    for(char m = '0';m<='9';m++){
                        string temp = "";
                        temp += i;
                        temp += j;
                        temp += k;
                        temp += l;
                        temp += m;
                        temp += temp;
                        vec.push_back(stoll(temp));
                    }
                }
            }
        }
    }
    for(char i = '1';i<='9';i++){
        for(char j = '0';j<='9';j++){
            for(char k = '0';k<='9';k++){
                for(char l = '0';l<='9';l++){
                    for(char m = '0';m<='9';m++){
                        for(char n = '0';n<='9';n++){
                            string temp = "";
                            temp += i;
                            temp += j;
                            temp += k;
                            temp += l;
                            temp += m;
                            temp += n;
                            temp += temp;
                            vec.push_back(stoll(temp));
                        }
                    }
                }
            }
        }
    }
    sort(vec.begin(),vec.end());
    ll n;
    cin>>n;
    int c = 0;
    for(int i = 0;i<vec.size();i++){
        if(vec[i] > n)break;
        c++;
    }
    cout<<c;
}

int main(){
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    #define int int64_t
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        string s = to_string(i);
        int num = stoll(s+s);
        //cout<<num<<endl;
        if(num>n){
            break;
        }
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}