// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    int val = 1;

    while(val*3 < n){

        val*=3;
        count++;
    }

    // db(n - val);

    int n2 = n - val; 
    // n-= val;
    int val2 = 1;


    while(val2*5 <= n2){

        val2*=5;
        sum++;
    }

   if(val2 == n2 && count && sum){

    cout<<count<<" "<<sum<<endl;

    return;
   }

   else{
    // cout<<-1<<endl;

    val = 1;

    count = 0;

    while(val*5 < n){

        val*=5;
        count++;
    }

    // db(n - val);

    n2 = n - val; 
    // n-= val;
    val2 = 1;
    sum = 0;

    while(val2*3 <= n2){

        val2*=3;
        sum++;
    }

    if(val2 == n2 && count && sum){

    cout<<sum<<" "<<count<<endl;
   }

   else{
    cout<<-1<<endl;
   }


   }

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;//10の18乗
#define yn {puts("Yes");}else{puts("No");}
#define dame { puts("-1"); return 0;}

int main() {
    ll n;
    cin >> n;
    ll now=1;
    ll mn=1,mx=9;
    chmin(mx,n);
    ll ans=0;
    rep(i,17){
        if(mn>mx) continue;
        ans+=(mx-mn+1)*((now-1)/3);
        now++;
        mn=mn*10;
        mx=(mx+1)*10-1;
        chmin(mx,n);
    }
    cout << ans << endl;
    
}
