#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
struct Edge {
    int to, cost;
    Edge(){};
    Edge(int to, int cost): to(to), cost(cost){};
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll n;
    cin >> n;
    int i = 1, j;
    for(ll a = 5; a < n; a *= 5) {
        j = 0;
        ll t = n - a;
        while (t % 3 == 0) {
            j++;
            t /= 3;
        }
        if (t == 1 && j != 0) {
            cout << j << ' ' << i << endl;
            return 0;
        }
        i++;
    }
    cout << -1 << endl;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll qpow(ll a,ll b)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b>>=1;
	}
	return ans;
}
int main()
{
	ll n;
	scanf("%lld",&n);
	for(ll i = 1;i<=38;i++){
		for(ll j = 1;j<=26;j++){
			if(qpow(3,i) + qpow(5,j) == n && qpow(3,i)>0 && qpow(5,j)>0){
				printf("%lld %lld",i,j);
				return 0;
			}
		}
	}
	printf("-1\n");
	//printf("%lld\n",qpow(3,35));
	return 0;
}