/* ** *** Be Name Khoda *** ** */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 10;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, z = 1;
    cin >> n;
    int x = 38, y = 26;
    vector<ll> v3, v5;
    while (x--)
    {
        z *= (ll)3LL;
        v3.push_back(z);
    }
    z = 1;
    while (y--)
    {
        z *= (ll)5LL;
        v5.push_back(z);
    }
    for (int i = 0; i < v3.size(); i++)
    {
        for (int j = 0; j < v5.size(); j++)
        {
            if (v3[i]+v5[j]<0) break;
            if (v3[i] + v5[j] == n)
                return cout << i+1 << ' ' << j+1, 0;
        }
    }
    cout << -1;
    return 0;
}
#include <bits/stdc++.h>
#include<sstream>
#include<string>
#include<vector>
#include <set>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
long long M=1000000007;
using namespace std;
ll fact[10000];
ll power(ll x, unsigned ll y, unsigned ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y / 2, m) % m; 
    p = (p * p) % m; 
  
    return (y % 2 == 0) ? p : (x * p) % m; 
} 
unsigned long long modInverse(unsigned long long n,  
                                            int p)
{
    return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
    // If n<r, then nCr should return 0
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
    return (fact[n] * modInverse(fact[r], p) % p
            * modInverse(fact[n - r], p) % p)
           % p;
}
int32_t main()
{
  IOS
  string s;
  cin>>s;
  cout<<s[1]<<s[2]<<s[0];
  return 0;
}
