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


#define int long long 


int chk(int x) {
	int cur = 1;
	for(int i = 1; true; i++) {
		if(cur > x / 3) return -1;
		cur *= 3;
		if(cur == x) return i;
	}
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int cur = 1;
	for(int i = 1; true; i++) {
		if(cur > n / 5) {
			cout << -1 << endl;
			return 0;
		}
		cur *= 5;
		if(chk(n - cur) > 0) {
			cout << chk(n - cur) << " " << i << endl;
			return 0;
		}
	}
}
#include "bits/stdc++.h"

#define all_of(x) std::begin(x), std::end(x)
#ifdef _GLIBCXX_DEBUG
    #define debug(x) cerr << #x << ": " << x << endl
#else
    #define debug(x) 
#endif

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}
template<typename T>
istream& operator >> (istream& in, vector<T>& v) {
    for(auto& x : v) {
        in >> x;
    }
    return in;
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    unsigned long long N;
    cin >> N;
    vector<unsigned long long> p3 = {1}, p5 = {1};
    while(p3.back() < N) {
        p3.push_back(p3.back() * 3);
    }
    while(p5.back() < N) {
        p5.push_back(p5.back() * 5);
    }
    for(int i = 1; i < int(p3.size()); ++i) {
        for(int j = 1; j < int(p5.size()); ++j) {
            if(p3[i] + p5[j] == N) {
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }
    cout << "-1\n";
    
    return 0;
}
