#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  cout << N-1;
}
#include <bits/stdc++.h>
using namespace std;

#define oo 1e18
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

const ll mod=1e9+7;

ll n,i,j,f1[5009],f2[5009];

int main(){
    IO;
    #ifndef ONLINE_JUDGE
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    #else
    #endif
    cin>>n;
    f1[0]=1;
    f2[0]=1;
    for (i=1;f1[i-1]<n;i++) {
        f1[i]=f1[i-1]*3;
    }
    for (i=1;f2[i-1]<n;i++) {
        f2[i]=f2[i-1]*5;
    }
    for (i=1;f2[i]<n;i++) {
        for (j=1;f1[j]<n;j++) {
            if (f1[j]+f2[i]==n) {
                cout<<j<<' '<<i;
                return 0;
            }
        }
    }
    cout<<-1;
}