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

int main(){
  long long N;
  cin >> N;
  
  int A = 1;
  long long pow3 = 1;
  while(pow3 < N){
    pow3 = pow3*3;
    long long res = N - pow3;
    int B = 0;
    while(res > 0){
      if(res%5 == 0){
        res = res/5;
        B++;
        if(res == 1){
          cout << A << " " << B << endl;
          return 0;
        }
      } else{
        A++;
        break;
      }
    }
  }
  
  cout << -1 << endl;
}
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;
typedef pair<int,int> pii;

int main() {
    ll pw3=3,pw5=5;
    ll n;
    cin>>n;
    for(int i=1;pw3<=n;++i) {
        pw5 = 5;
        for(int j=1;pw5<=n;++j) {
            if(pw3 + pw5 == n) {
                cout << i << " " << j << endl;
                return 0;
            }
            pw5 = pw5 * 5;
        }
        pw3 = pw3 * 3;
    }
    cout << -1 << endl;
}