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;
void debug(vector<int> &a) {
  printf("%d", a[a.size() - 1]);
  for (int i = a.size() - 2; i >= 0; i--) printf("%02d", a[i]);
  printf("\n");
}
double PI = acos(-1.0);
struct Complex {
  double x, y;
  Complex() {}
  Complex(double a, double b) : x(a), y(b) {}
  Complex operator+(Complex b) { return Complex(x + b.x, y + b.y); }
  Complex operator-(Complex b) { return Complex(x - b.x, y - b.y); }
  Complex operator*(Complex b) {
    return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
  }
};
void rev(Complex *p, int len) {
  int j = len >> 1;
  for (int i = 1; i < len - 1; i++) {
    if (i < j) swap(p[i], p[j]);
    int k = len >> 1;
    while (j >= k) {
      j -= k;
      k >>= 1;
    }
    if (j < k) j += k;
  }
}
void fft(Complex *p, int len, int check) {
  rev(p, len);
  for (int i = 2; i <= len; i <<= 1) {
    Complex wn(cos(2 * PI / i), sin(2 * PI / i));
    for (int j = 0; j < len; j += i) {
      Complex w(1, 0);
      for (int k = j; k < j + (i >> 1); k++) {
        Complex u = p[k];
        Complex v = w * p[k + (i >> 1)];
        p[k] = u + v;
        p[k + (i >> 1)] = u - v;
        w = w * wn;
      }
    }
  }
  if (check == -1) {
    reverse(p + 1, p + len);
    for (int i = 0; i < len; i++) p[i].x /= len;
  }
}
Complex p[1 << 22], q[1 << 22];
void mul(vector<int> &a, vector<int> &b, vector<int> &c) {
  int len = 1;
  while (len < a.size() + b.size()) len <<= 1;
  for (int i = 0; i < a.size(); i++) p[i] = Complex(a[i], 0);
  for (int i = a.size(); i < len; i++) p[i] = Complex(0, 0);
  for (int i = 0; i < b.size(); i++) q[i] = Complex(b[i], 0);
  for (int i = b.size(); i < len; i++) q[i] = Complex(0, 0);
  fft(p, len, 1);
  fft(q, len, 1);
  for (int i = 0; i < len; i++) p[i] = p[i] * q[i];
  fft(p, len, -1);
  c.resize(a.size() + b.size() - 1);
  for (int i = 0; i < c.size(); i++) c[i] = (int)(p[i].x + 0.5);
}
void expand(vector<int> &a) {
  int g = 0;
  for (int i = 0; i < a.size(); i++) {
    a[i] += g;
    g = a[i] / 100;
    a[i] %= 100;
  }
  while (g) {
    a.push_back(g % 100);
    g /= 100;
  }
}
void polypow(vector<int> &a, vector<int> &b, int k) {
  a.resize(1);
  a[0] = 3;
  b.resize(1);
  b[0] = 1;
  while (k) {
    if (k & 1) {
      mul(a, b, b);
      expand(b);
    }
    mul(a, a, a);
    expand(a);
    k >>= 1;
  }
}
bool cmp(vector<int> &a, vector<int> &b) {
  if (a.size() != b.size()) return a.size() > b.size();
  for (int i = a.size() - 1; i >= 0; i--)
    if (a[i] != b[i]) return a[i] > b[i];
  return 1;
}
char str[2000000];
vector<int> a, b, c;
bool check(vector<int> &t, int x) {
  static vector<int> now;
  now = t;
  for (int i = 0; i < now.size(); i++) now[i] *= x;
  expand(now);
  return cmp(now, a);
}
int main() {
  scanf("%s", str);
  int len = strlen(str);
  reverse(str, str + len);
  for (int i = 0; i < len; i += 2) {
    int s = str[i] - '0';
    if (i + 1 < len) s += (str[i + 1] - '0') * 10;
    a.push_back(s);
  }
  int t = (double)(len - 1) * log(10) / log(3);
  if (t) t--;
  polypow(c, b, t);
  int ans = 3 * t;
  while (!cmp(b, a)) {
    if (check(b, 2)) {
      ans += 2;
      break;
    }
    if (check(b, 3)) {
      ans += 3;
      break;
    }
    if (check(b, 4)) {
      ans += 4;
      break;
    }
    for (int i = 0; i < b.size(); i++) b[i] *= 3;
    expand(b);
    ans += 3;
  }
  printf("%d\n", max(ans, 1));
  return 0;
}