#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
   int ps = 5;
   int i = 1;
    
   while(ps <= n)
   {
      int v = n - ps;
      int cnt = 0;
       
      while(v % 3 == 0 && (v > 1))
      {
          v/=3;
          cnt++;
      }
       
      if(v == 1 && cnt > 0)
      {
          cout << cnt << ' ' << i;
          exit(0);
      }
       
      i++; 
      
      if((n/5) < ps) break; 
       
      ps*=5; 
       
   }
    
   cout << -1;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

#include <bits/stdc++.h>
using namespace std;

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define LL long long
#define ULL unsigned long long
#define LB lower_bound
#define MOD1 1000000007
#define MOD2 1000000009
#define int LL
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
const int maxn = 1e5 + 1;
string s;

bool solve()
{
    if (s.size() < 3)
    {
        int n = stoll(s);
        if (n % 8 == 0)
            return 1;
        string temp(s);

        reverse(temp.begin(), temp.end());
        n = stoll(temp);
        if (n % 8 == 0)
            return 1;

        return 0;
    }

    unordered_map<int, int> mp;
    for (auto &i : s)
    {
        i -= '0';
        mp[i]++;
    }


    for (int i = 104; i < 1000; i += 8)
    {
      int orig = i; 
        int freq[10] = { 0 }; 
        freq[orig % 10]++; 
        orig = orig / 10; 
        freq[orig % 10]++; 
        orig = orig / 10; 
        freq[orig % 10]++; 
  
        orig = i; 
        if (freq[orig % 10] > mp[orig % 10]) 
            continue; 
        orig = orig / 10; 
  
        if (freq[orig % 10] > mp[orig % 10]) 
            continue; 
        orig = orig / 10; 
  
        if (freq[orig % 10] > mp[orig % 10]) 
            continue; 
  
        return true; 
    }
    return 0;
}

signed main()
{
    int t = 1;
    // cin >> t;

    while (t--)
    {
        cin >> s;
        if (solve())
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}