//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007

ll check(ll x)
{
    ll c = 0;
    while(x % 5 == 0)
    {
         x /= 5;
         c++;
    }

    if(x > 1)
        return MAX;

    return c;
}

void solve()
{
     ll n;
     cin >> n;

     ll p = 1;
     ll c = 0;
     while(p < n / 3) {

         p *= 3;
         c++;

         ll r = n - p;

         if(check(r) != MAX) {
            cout << c << " " << check(r) << endl;
            return;
         }

     }

     cout << -1;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}


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

// #define int long long
#define pb push_back
#define vt std::vector
#define lb lower_bound
#define sz(x) (int(x.size()))
#define all(x) x.begin(), x.end()
#define mst(x, bit) memset(x, bit, sizeof(x))
#define rep(i, l, r) for (ll i = (l); i < (r); ++ i)
#define forr(i, l, r) for (ll i = (l); i >= (r); -- i)
#define dmp(x) cerr << __LINE__ << "->" << #x << " " << x << "\n"

using ll = long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename... Args>
inline void _wpr_(Args... args) { std::cout << '\n'; }
template<typename T, typename... Args>
inline void _wpr_(T val, Args... args) { std::cout << " " << val; _wpr_(args...); }
template<typename T, typename... Args>
void wpr(T val, Args... args) { std::cout << val; _wpr_(args...); }

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e5 + 50;

// 对于这种不断递推的，先写出预处理式子，再用for循环处理（方便）

void solve(){
    // < 1,000 +1
    // < 1,000,000 + 2
    // < 1,000,000,000 + 3
    ll n; std::cin >> n;
    vt<ll> add(10);
    iota(all(add), 0ll);
    
    ll base = 1, ans = 0;
    for (int i = 0;; ++ i, base *= 1000){
        if (base * 1000 > n) { ans += (n - base + 1) * add[i]; break; }
        else ans += (1000 * base - base) * add[i];
    }

    wpr(ans);
}

signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // std::cin >> t;
    while (t--) solve();
    return 0;
}
