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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 21) + 1;
const double PI = acos(-1.0);
int m;
char s[N];
int bit = 1000;
struct Big {
  int len;
  long long a[N];
  void clear() {
    len = 0;
    memset(a, 0, sizeof a);
  }
  void print() {
    for (int i = len; i >= 1; i--) printf("%03d", (int)a[i]);
    puts("");
  }
  bool operator>=(Big &x) {
    if (len != x.len) return len > x.len;
    for (int i = len; i >= 1; i--)
      if (a[i] != x.a[i]) return a[i] > x.a[i];
    return 1;
  }
  void pushbits() {
    for (int i = 1; i <= len; i++) a[i + 1] += a[i] / bit, a[i] %= bit;
    while (a[len + 1]) {
      len++;
      a[len + 1] = a[len] / bit;
      a[len] %= bit;
    }
  }
  void operator*=(int x) {
    for (int i = 1; i <= len; i++) a[i] *= x;
    pushbits();
  }
} n, x, tmp;
struct C {
  double r, i;
  C() {}
  C(double _r, double _i) { r = _r, i = _i; }
  C operator+(C x) { return C(r + x.r, i + x.i); }
  C operator-(C x) { return C(r - x.r, i - x.i); }
  C operator*(C x) { return C(r * x.r - i * x.i, r * x.i + i * x.r); }
} A[N], B[N], w[N];
int R[N];
void FFT(C a[], int n) {
  for (int i = 0; i < n; i++)
    if (R[i] > i) swap(a[i], a[R[i]]);
  for (int t = n >> 1, d = 1; d < n; d <<= 1, t >>= 1)
    for (int i = 0; i < n; i += (d << 1))
      for (int j = 0; j < d; j++) {
        C tmp = w[t * j] * a[i + j + d];
        a[i + j + d] = a[i + j] - tmp;
        a[i + j] = a[i + j] + tmp;
      }
}
void Times(Big &a, Big &b, Big &c) {
  int n, d;
  for (n = 1, d = 0; n < a.len + b.len; n <<= 1, d++)
    ;
  for (int i = 0; i < n; i++) {
    R[i] = (R[i >> 1] >> 1) | ((i & 1) << (d - 1));
    w[i] = C(cos(PI * 2 * i / n), sin(PI * 2 * i / n));
    A[i] = B[i] = C(0, 0);
  }
  for (int i = 1; i <= a.len; i++) A[i - 1].r = a.a[i];
  for (int i = 1; i <= b.len; i++) B[i - 1].r = b.a[i];
  FFT(A, n), FFT(B, n);
  for (int i = 0; i < n; i++) A[i] = A[i] * B[i], w[i].i *= -1.0;
  FFT(A, n);
  c.clear();
  for (int i = 0; i < n; i++) c.a[i + 1] = (long long)(A[i].r / n + 0.5);
  c.len = n;
  while (c.a[c.len] == 0 && c.len > 1) c.len--;
  c.pushbits();
}
void Pow(int y) {
  if (y == 0) {
    x.clear();
    x.a[x.len = 1] = 1;
    return;
  }
  Pow(y / 2);
  Times(x, x, x);
  if (y & 1) x *= 3;
}
bool check(Big &x, int y) {
  tmp = x;
  tmp *= y;
  return tmp >= n;
}
int main() {
  scanf("%s", s + 1);
  n.len = strlen(s + 1);
  reverse(s + 1, s + n.len + 1);
  for (int i = 1; i <= n.len; i += 3) {
    if ('0' <= s[i] && s[i] <= '9') n.a[i / 3 + 1] += (s[i] - '0');
    if ('0' <= s[i + 1] && s[i + 1] <= '9')
      n.a[i / 3 + 1] += (s[i + 1] - '0') * 10;
    if ('0' <= s[i + 2] && s[i + 2] <= '9')
      n.a[i / 3 + 1] += (s[i + 2] - '0') * 100;
  }
  m = max(0, (int)(n.len * log(10) / log(3)) - 3);
  n.len = (n.len - 1) / 3 + 1;
  if (n.len == 1 && n.a[1] == 1) {
    puts("1");
    return 0;
  }
  Pow(m);
  while (1) {
    for (int i = 2; i <= 4; i++)
      if (check(x, i)) {
        printf("%d", m * 3 + i);
        return 0;
      }
    x *= 3;
    m++;
  }
  return 0;
}