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

const int inf  = 1e18+9;
const int mod  = 1e9+7;
const int maxn = 2e5+8;

int n, m;

void solve() {
    int i, j;
    map<int, int> mp;
    cin >> n;
    for (int x = 3, i = 1; x < n; i++, x *= 3) mp[x] = i;
    for (int x = 5, i = 1; x < n; i++, x *= 5) if (mp.find(n - x) != mp.end()) return (void)(cout << mp[n - x] << " " << i << endl);
    cout << -1 << endl;
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); //cout << fixed << setprecision(15);
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}


#include <iostream>

using namespace std;

// a^p
uint64_t my_p(uint64_t a, int p)
{
    uint64_t ans = 1;
    for (int i = 0; i < p; ++i) { ans *= a;}

    return ans;
}

int main()
{
    uint64_t N;
    cin >> N;

    for (int i = 1; i < 38; ++i)
    {
        for (int j = 1; j < 26; ++j)
        {
            uint64_t a = my_p(3, i) + my_p(5, j);
			if (a == N)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    
    cout << -1 << endl;
    return 0;
}
