#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
 
using ll = long long;
using ld = long double;
using namespace std;

map<ll, int> m;
ll n;

int main() {
	scanf ("%lld", &n);
	ll three = 3, cnt = 1;
	while (three <= n) {
		m[three] = cnt;
		three *= 3;
		cnt++;
	}
	ll five = 5;
	cnt = 1;
	while (five <= n) {
		if (m[n - five]) return !printf ("%d %lld\n", m[n - five], cnt);
		five *= 5;
		cnt++;
	}
	printf ("-1\n");
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define amax(a, b) a = max(a, b)
#define amin(a, b) a = min(a, b)

using ll = long long;

int pow5(ll x) {
    int cnt = 0;
    while (x % 5 == 0) {
        x /= 5;
        cnt++;
    }
    return (x == 1 ? cnt : 0);
}

int main() {
    ll n;
    std::cin >> n;
    for (ll p3 = 3, a = 1; p3 < n; p3 *= 3, a++) {
        if (int b = pow5(n - p3); b > 0) {
            std::cout << a << ' ' << b << '\n';
            return 0;
        }
    }
    std::cout << -1 << '\n';
    return 0;
}