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;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "Yes" : "No");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
int pp[] = {0, 100030001, 100060001, 113111311, 114535411}, delta = 1000000;
struct BigInt {
  vector<int> v;
  BigInt(char st[], int n) {
    v.resize(n);
    for (int(i) = 0; (i) < (int)(n); (i)++) v[i] = st[n - 1 - i] - '0';
  }
  inline void detrail() {
    while (!v.empty() && !v.back()) v.pop_back();
  }
  inline void comein() {
    v.push_back(0);
    for (int i = 0; i + 1 < (int)v.size(); ++i) {
      v[i + 1] += v[i] / 10;
      v[i] %= 10;
    }
    detrail();
  }
  inline void add_one() {
    v[0]++;
    comein();
  }
  inline int hash(int p) {
    long long x = 0;
    for (int i = (int)v.size() - 1; i >= 0; i--) {
      x = x * 10 + v[i];
      x %= p;
    }
    return x;
  }
  inline void div_2() {
    if (v[0] & 1) add_one();
    v[0] >>= 1;
    for (int i = 0; i + 1 < (int)v.size(); ++i) {
      v[i] += (v[i + 1] & 1) * 5;
      v[i + 1] >>= 1;
    }
    detrail();
  }
  inline int log_3() {
    int l = min(15, (int)v.size());
    long long x = 0;
    for (int i = (int)v.size() - 1; i >= (int)v.size() - l; i--)
      x = x * 10 + v[i];
    double w = (log(x) + ((int)v.size() - l) * log(10)) / log(3);
    int t = w, cnt = 0;
    t += (t + 1 - w < 1e-9);
    for (int(i) = 1; (i) <= (int)(4); (i)++) {
      int xx = fastPow(3, t, pp[i]), yy = hash(pp[i]);
      cnt += (xx - yy > 0 && xx - yy <= delta);
    }
    if (cnt == 4) --t;
    for (int(i) = 1; (i) <= (int)(4); (i)++)
      if (fastPow(3, t, pp[i]) != hash(pp[i])) return t + 1;
    return t;
  }
};
char s[1500105];
void fmain(int ID) {
  scanf("%s", s);
  n = strlen(s);
  if (n == 1 && s[0] == '1') {
    puts("1");
    return;
  }
  BigInt b = BigInt(s, n);
  int ans = b.log_3() * 3;
  for (int(i) = 1; (i) <= (int)(2); (i)++) {
    b.div_2();
    mintt(ans, b.log_3() * 3 + i * 2);
  }
  printf("%d\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}