#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <set>
#include <unordered_set>
#include <functional>
#include <map>
#include <unordered_map>
#include <string>
#include <tuple>
using namespace std;
using ll = long long;

#define pi 3.14159265358979323846
#define ee 2.71828182845904523536
#define INF 1e18+1

long long gcd(long long x, long long y) { // 最大公約数
    if (y == 0)return x;
    else return gcd(y, x % y);
}

bool prime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)return false;
    }
    return true;
}

long long modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0)u += m;
    return u;
}

struct UnionFind {   // UnionFind
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N), siz(N, 1) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry])swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(int x) {
        return siz[root(x)];
    }
};

int main() {
    ll n;
    cin >> n;
    ll cnt = 3;
    ll sum3 = 1;
    while (n > cnt) {
        if ((n - cnt) % 5 == 0) {
            ll cn5 = 5;
            ll sum5 = 1;
            while (n - cnt >= cn5) {
                if (n - cnt == cn5) {
                    cout << sum3 << " " << sum5 << endl;
                    return 0;
                }
                cn5 *= 5;
                sum5++;
            }
        }
        cnt *= 3;
        sum3++;
    }
    cout << -1 << endl;
}
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define endl "\n"
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
vector<ll>as;
ll check(ll n){
    if(n<1){
        return -1;
    }
    for(int i=0;i<as.size();i++){
        if(as[i]==n){
            return i+1;
        }
    }
    return -1;
}
int main() {
    FIO;
    ll n,l=-1,r=-1,p,count=1;
    cin>>n;
    p=5ll;
    while(p<n){
        as.push_back(p);
        p*=5;
    }
    p=3ll;
    while(true){
        if(p<n && check(n-p)!=-1){
            l=count;
            r=check(n-p);
            break;
        }
        if(p*3<n){
            p*=3;
            count++;
        }
        else{
            break;
        }
    }
    if(l==-1) cout<<"-1"<<endl;
    else cout<<l<<" "<<r<<endl;
    //cout<<(l==-1?"-1\n":l<<" "<<r<<endl;)
	return 0;
}
