
#include <bits/stdc++.h>

#define int long long

using namespace std;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;

    for(int i = 3, c1 = 1 ; i <= 1e18 ; i*=3, c1++)
    {
    	for(int j = 5, c2 = 1 ; j <= 1e18 ; j*=5, c2++)
    	{
    		if(i+j == N)
    		{
    			cout << c1 << " " << c2 << '\n';
    			return 0;
    		}
    	}
    }

    cout << -1 << '\n';

    return 0;
}
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=long long>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class T>auto comp_pairs_by_second(){return[](const T&p1,const T&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);};}

int main()
{
    vector<ll>p3{3},p5{5};
    while(p3.back()<static_cast<ll>(1e+18))p3.push_back(p3.back()*3);
    while(p5.back()<static_cast<ll>(1e+18))p5.push_back(p5.back()*5);
    ll n=in();
    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 0;
            }
        }
    }
    cout<<"-1"<<endl;
}
