#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 1500013;
const int MAXL = 1100013;
const int MAXS = 10000;
const long double PI = acos(-1.0);
int n;
char s[MAXN];
int ls, ia[MAXN], ki;
int bs[MAXL], nv[MAXL], tmp[MAXL];
long long tans[MAXL];
complex<double> cp[MAXL], ca[MAXL], cb[MAXL], cans[MAXL], rt[MAXL];
void init();
void input();
void work();
void fft(complex<double> ar[], int tn);
int mul(int a[], int n, int b[], int m, int ans[]);
int polymul(int a[], int n, int x, int ans[]);
bool polyle(int a[], int n, int b[], int m);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() { scanf("%s", s); }
void work() {
  ls = strlen(s);
  reverse(s, s + ls);
  for (int i = ls; i < ls + 7; ++i) s[i] = '0';
  for (int i = 0; i < ls; i += 4)
    ia[ki++] = (s[i + 3] - '0') * 1000 + (s[i + 2] - '0') * 100 +
               (s[i + 1] - '0') * 10 + (s[i] - '0');
  --ki;
  int m3 = static_cast<int>(
          floor((ls - 2) / log10(static_cast<long double>(3)))),
      baseans = (((m3) > (0)) ? (m3) : (0)), bl, nl;
  if (m3 > 0) {
    bl = 0, nl = 0;
    bs[0] = 3;
    nv[0] = 1;
    while (m3) {
      if (m3 & 1) nl = mul(nv, nl, bs, bl, nv);
      bl = mul(bs, bl, bs, bl, bs);
      m3 >>= 1;
    }
  } else
    nl = 0, nv[0] = 1;
  int ans = INF, cv;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 2; ++j) {
      int coef = ((i == 0) ? 1 : (i == 1) ? 2 : 4) * ((j == 0) ? 1 : 5);
      cv = baseans * 3 + i * 2 + j * 5;
      int tl = polymul(nv, nl, coef, tmp);
      while (polyle(tmp, tl, ia, ki)) tl = polymul(tmp, tl, 3, tmp), cv += 3;
      ans = (((ans) < (cv)) ? (ans) : (cv));
    }
  }
  cout << (((ans) > (1)) ? (ans) : (1)) << endl;
}
void fft(complex<double> ar[], int tn) {
  for (int i = 0, j = 0; i < tn; ++i) {
    if (i > j) swap(ar[i], ar[j]);
    for (int bt = tn >> 1; bt && (!((j ^= bt) & bt)); bt >>= 1)
      ;
  }
  int m;
  complex<double> x, y;
  for (int i = 2; i <= tn; i <<= 1) {
    m = i >> 1;
    for (int j = 0; j < tn; j += i) {
      for (int k = 0; k < m; ++k) {
        x = ar[j + k], y = ar[j + k + m] * rt[tn / i * k];
        ar[j + k] = x + y;
        ar[j + k + m] = x - y;
      }
    }
  }
}
int mul(int a[], int n, int b[], int m, int ans[]) {
  int tn = 1, nm = n + m, ub = (((n) > (m)) ? (n) : (m));
  while (tn <= nm) tn <<= 1;
  for (int i = 0; i < tn; ++i)
    rt[i] = complex<double>(cos(2 * PI * i / tn), sin(2 * PI * i / tn));
  for (int i = 0; i <= ub; ++i) cp[i] = complex<double>(a[i], b[i]);
  for (int i = ub + 1; i < tn; ++i) cp[i] = 0;
  fft(cp, tn);
  cp[tn] = cp[0];
  for (int i = 0; i < tn; ++i)
    cans[i] = ((cp[i] + conj(cp[tn - i])) / complex<double>(2, 0)) *
              ((conj(cp[tn - i]) - cp[i]) * complex<double>(0, 0.5)),
    rt[i] = conj(rt[i]);
  fft(cans, tn);
  for (int i = 0; i <= nm; ++i)
    tans[i] = static_cast<long long>(floor(cans[i].real() / tn + 0.5));
  for (int i = nm + 1; i <= nm + 7; ++i) tans[i] = 0;
  for (int i = 0; i <= nm + 7; ++i) {
    tans[i + 1] += tans[i] / MAXS;
    ans[i] = tans[i] % MAXS;
  }
  while (ans[nm + 1]) ++nm;
  return nm;
}
int polymul(int a[], int n, int x, int ans[]) {
  for (int i = 0; i <= n; ++i) ans[i] = a[i] * x;
  for (int i = n + 1; i <= n + 7; ++i) ans[i] = 0;
  for (int i = 0; i <= n + 7; ++i) ans[i + 1] += ans[i] / MAXS, ans[i] %= MAXS;
  while (ans[n + 1]) ++n;
  return n;
}
bool polyle(int a[], int n, int b[], int m) {
  if (n ^ m) return (n < m);
  for (int i = n; i >= 0; --i)
    if (a[i] ^ b[i]) return a[i] < b[i];
  return false;
}

### Prompt

Create a solution in Cpp for the following problem:

You are working as an analyst in a company working on a new system for big data storage. This system will store n different objects. Each object should have a unique ID.

To create the system, you choose the parameters of the system — integers m ≥ 1 and b_{1}, b_{2}, …, b_{m}. With these parameters an ID of some object in the system is an array of integers [a_{1}, a_{2}, …, a_{m}] where 1 ≤ a_{i} ≤ b_{i} holds for every 1 ≤ i ≤ m.

Developers say that production costs are proportional to ∑_{i=1}^{m} b_{i}. You are asked to choose parameters m and b_{i} so that the system will be able to assign unique IDs to n different objects and production costs are minimized. Note that you don't have to use all available IDs.

Input

In the only line of input there is one positive integer n. The length of the decimal representation of n is no greater than 1.5 ⋅ 10^{6}. The integer does not contain leading zeros.

Output

Print one number — minimal value of ∑_{i=1}^{m} b_{i}.

Examples

Input

36


Output

10


Input

37


Output

11


Input

12345678901234567890123456789


Output

177

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 1500013;
const int MAXL = 1100013;
const int MAXS = 10000;
const long double PI = acos(-1.0);
int n;
char s[MAXN];
int ls, ia[MAXN], ki;
int bs[MAXL], nv[MAXL], tmp[MAXL];
long long tans[MAXL];
complex<double> cp[MAXL], ca[MAXL], cb[MAXL], cans[MAXL], rt[MAXL];
void init();
void input();
void work();
void fft(complex<double> ar[], int tn);
int mul(int a[], int n, int b[], int m, int ans[]);
int polymul(int a[], int n, int x, int ans[]);
bool polyle(int a[], int n, int b[], int m);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() { scanf("%s", s); }
void work() {
  ls = strlen(s);
  reverse(s, s + ls);
  for (int i = ls; i < ls + 7; ++i) s[i] = '0';
  for (int i = 0; i < ls; i += 4)
    ia[ki++] = (s[i + 3] - '0') * 1000 + (s[i + 2] - '0') * 100 +
               (s[i + 1] - '0') * 10 + (s[i] - '0');
  --ki;
  int m3 = static_cast<int>(
          floor((ls - 2) / log10(static_cast<long double>(3)))),
      baseans = (((m3) > (0)) ? (m3) : (0)), bl, nl;
  if (m3 > 0) {
    bl = 0, nl = 0;
    bs[0] = 3;
    nv[0] = 1;
    while (m3) {
      if (m3 & 1) nl = mul(nv, nl, bs, bl, nv);
      bl = mul(bs, bl, bs, bl, bs);
      m3 >>= 1;
    }
  } else
    nl = 0, nv[0] = 1;
  int ans = INF, cv;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 2; ++j) {
      int coef = ((i == 0) ? 1 : (i == 1) ? 2 : 4) * ((j == 0) ? 1 : 5);
      cv = baseans * 3 + i * 2 + j * 5;
      int tl = polymul(nv, nl, coef, tmp);
      while (polyle(tmp, tl, ia, ki)) tl = polymul(tmp, tl, 3, tmp), cv += 3;
      ans = (((ans) < (cv)) ? (ans) : (cv));
    }
  }
  cout << (((ans) > (1)) ? (ans) : (1)) << endl;
}
void fft(complex<double> ar[], int tn) {
  for (int i = 0, j = 0; i < tn; ++i) {
    if (i > j) swap(ar[i], ar[j]);
    for (int bt = tn >> 1; bt && (!((j ^= bt) & bt)); bt >>= 1)
      ;
  }
  int m;
  complex<double> x, y;
  for (int i = 2; i <= tn; i <<= 1) {
    m = i >> 1;
    for (int j = 0; j < tn; j += i) {
      for (int k = 0; k < m; ++k) {
        x = ar[j + k], y = ar[j + k + m] * rt[tn / i * k];
        ar[j + k] = x + y;
        ar[j + k + m] = x - y;
      }
    }
  }
}
int mul(int a[], int n, int b[], int m, int ans[]) {
  int tn = 1, nm = n + m, ub = (((n) > (m)) ? (n) : (m));
  while (tn <= nm) tn <<= 1;
  for (int i = 0; i < tn; ++i)
    rt[i] = complex<double>(cos(2 * PI * i / tn), sin(2 * PI * i / tn));
  for (int i = 0; i <= ub; ++i) cp[i] = complex<double>(a[i], b[i]);
  for (int i = ub + 1; i < tn; ++i) cp[i] = 0;
  fft(cp, tn);
  cp[tn] = cp[0];
  for (int i = 0; i < tn; ++i)
    cans[i] = ((cp[i] + conj(cp[tn - i])) / complex<double>(2, 0)) *
              ((conj(cp[tn - i]) - cp[i]) * complex<double>(0, 0.5)),
    rt[i] = conj(rt[i]);
  fft(cans, tn);
  for (int i = 0; i <= nm; ++i)
    tans[i] = static_cast<long long>(floor(cans[i].real() / tn + 0.5));
  for (int i = nm + 1; i <= nm + 7; ++i) tans[i] = 0;
  for (int i = 0; i <= nm + 7; ++i) {
    tans[i + 1] += tans[i] / MAXS;
    ans[i] = tans[i] % MAXS;
  }
  while (ans[nm + 1]) ++nm;
  return nm;
}
int polymul(int a[], int n, int x, int ans[]) {
  for (int i = 0; i <= n; ++i) ans[i] = a[i] * x;
  for (int i = n + 1; i <= n + 7; ++i) ans[i] = 0;
  for (int i = 0; i <= n + 7; ++i) ans[i + 1] += ans[i] / MAXS, ans[i] %= MAXS;
  while (ans[n + 1]) ++n;
  return n;
}
bool polyle(int a[], int n, int b[], int m) {
  if (n ^ m) return (n < m);
  for (int i = n; i >= 0; --i)
    if (a[i] ^ b[i]) return a[i] < b[i];
  return false;
}

```