#include <bits/stdc++.h>
#include <fstream>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define printarr(v) for(auto& x : v) cout<<x<<" "; cout<<endl

using namespace std;


char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const int MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };


bool five(ll n){
    ll curr=5;
    while(curr<n) curr*=5;
    if(curr==n) return true;
    return false;
}

void solve() {
    
    ll n;
    cin>>n;
    ll curr=3, cnt=1;
    while(curr<n){
        if(five(n-curr)){
            cout<<cnt<<" ";
            n-=curr;
            ll c=0;
            while(pow(5, c)<n) c++;
            cout<<c<<endl;
            return;
        }
        curr*=3;
        cnt++;
    }
    cout<<"-1"<<endl;
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
   
    
       // tests
        solve();


    return 0;
}





#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    long long N,i,j,arr1[38]={0},arr2[38]={0},M=0;
    cin >> N;
    arr1[0] = 1;
    arr2[0] = 1;
    arr1[1] = 3;
    arr2[1] = 5;
    for(i=2;i<38;i++){
        arr1[i] = arr1[i-1]*3;
        arr2[i] = arr2[i-1]*5;
    }
    for(i=1;i<=38&&M<N;i++){
        for(j=1;j<=25&&M<N;j++){
            if(arr1[i]+arr2[j] == N){
                cout << i <<" "<< j;
                return 0;
            }
        }
    }
    cout << -1 ;
}
