#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	ll n;
	cin>>n;
	for(ll i=0;;i++){
		if(stoll(to_string(i)+to_string(i))>n){
			cout<<i-1<<endl;
			return 0;
		}
	}
	cout<<n/11<<endl;
}

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

//解答
int main(){
    string S;
    cin >> S;

    reverse(S.begin(),S.end());
    for(int i=0;i<S.length();i++){
        if(S[i] == '6'){
            S.erase(i,1);
            S.insert(i,"9");
        }else if(S[i] == '9'){
            S.erase(i,1);
            S.insert(i,"6");
        }
    }

    cout << S << endl;

}
