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

int main(){
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 1; i <= (n-1)/2; i++){
        ans += 9*pow(10,i-1);
    }
    if(n%2 == 0){
        string sl = s.substr(0,n/2);
        string sr = s.substr(n/2);
        ans += stoi(sl)-pow(10,n/2-1)+1;
        if(sl > sr) ans--;
    }

    cout << ans << endl;
}
#include <bits/stdc++.h>
 
#define ll long long
#define ull unsigned long long
using namespace std;
void solve()
{
    ull MAX = 1e18;//((ull)1)<<60;
    //cerr<<MAX<<endl;
    ull n;
    cin>>n;
    vector<ull> P3, P5;
    ull z = 3;
    while(z<MAX) {
        P3.push_back(z);
        z*=3;
    }
    z = 5;
    while(z<MAX) {
        P5.push_back(z);
        z*=5;
    }
    for(int i=0; i<P3.size(); ++i)
        for(int j=0; j<P5.size(); ++j)
            if(P3[i]+P5[j] == n){
                cout<<(i+1)<<" "<<(j+1)<<endl;
                return;
            }
    cout<<-1<<endl;
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int T = 1;
    //cin>>T;
    while(T--)
        solve();
    
		
	return 0;
}