#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int log3(lli N){

  int a=-1;
  while(N>0){
  a++;
    N/=3;
  
  }
  return a;

}int log5(lli N){

  int a=-1;
  while(N>0){
  a++;
    N/=5;
  
  }
  return a;

}

int main() {
  lli N;
  cin >> N;
  int three, five;
  three=log3(N)+1;
  five=log5(N)+1;
  lli a=1, b=1;
  
  rep(i, three){
    a*=3;
  rep(j, five){
  b*=5;
  if(a+b==N){
  cout << i+1 <<" "<<j+1 << endl;  
    return 0;
  }
  }
  b=1;
  
  }
  cout << -1 << endl;
}
#include<iostream>
#include<stack>
using namespace std;
const int maxsize = 1e5 + 5;
long long l3[maxsize];
long long l5[maxsize];
int main() {
	long long n;
	long long x = 1;
	long long i = 0,j = 0;
	cin >> n;
	while (x < n) {
		x *= 3;
		l3[++i] = x;
	}
	x = 1;
	while (x < n) {
		x *= 5;
		l5[++j] = x;
	}
	for (int m = 1; m <= i; m++) {
		for (int k = 1; k <= j; k++) {
			if (l3[m] + l5[k] == n) {
				cout << m << " " << k;
				return 0;
			}
			else if (l3[m] + l5[k] > n)
				break;
		}
	}
	cout << "-1";
	return 0;
}