#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 22;
struct CD {
  double r, i;
  CD(double r = 0, double i = 0) : r(r), i(i) {}
  double real() const { return r; }
  void operator/=(const int c) { r /= c, i /= c; }
};
CD operator*(const CD &a, const CD &b) {
  return CD(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r);
}
CD operator+(const CD &a, const CD &b) { return CD(a.r + b.r, a.i + b.i); }
CD operator-(const CD &a, const CD &b) { return CD(a.r - b.r, a.i - b.i); }
const double pi = acos(-1);
CD cp1[MAXN + 9], cp2[MAXN + 9];
int R[MAXN + 9];
void dft(CD *a, int n, bool inv) {
  for (int i = 0, ThxDem = n; i < ThxDem; ++i)
    if (R[i] < i) swap(a[R[i]], a[i]);
  for (int m = 2; m <= n; m *= 2) {
    double z = 2 * pi / m * (inv ? -1 : 1);
    CD wi = CD(cos(z), sin(z));
    for (int j = 0; j < n; j += m) {
      CD w(1);
      for (int k = j, k2 = j + m / 2; k2 < j + m; k++, k2++) {
        CD u = a[k];
        CD v = a[k2] * w;
        a[k] = u + v;
        a[k2] = u - v;
        w = w * wi;
      }
    }
  }
  if (inv)
    for (int i = 0, ThxDem = n; i < ThxDem; ++i) a[i] /= n;
}
vector<int> multiply(vector<int> &p1, vector<int> &p2) {
  int n = int(p1.size()) + int(p2.size()) + 1;
  int m = 1, cnt = 0;
  while (m <= n) m += m, cnt++;
  for (int i = 0, ThxDem = m; i < ThxDem; ++i) {
    R[i] = 0;
    for (int j = 0, ThxDem = cnt; j < ThxDem; ++j)
      R[i] = (R[i] << 1) | ((i >> j) & 1);
  }
  for (int i = 0, ThxDem = m; i < ThxDem; ++i) cp1[i] = 0, cp2[i] = 0;
  for (int i = 0, ThxDem = p1.size(); i < ThxDem; ++i) cp1[i] = p1[i];
  for (int i = 0, ThxDem = p2.size(); i < ThxDem; ++i) cp2[i] = p2[i];
  dft(cp1, m, 0);
  dft(cp2, m, 0);
  for (int i = 0, ThxDem = m; i < ThxDem; ++i) cp1[i] = cp1[i] * cp2[i];
  dft(cp1, m, 1);
  n -= 2;
  vector<int> res;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i)
    res.push_back((long long)floor(cp1[i].real() + .5));
  return res;
}
vector<int> mul(vector<int> &x, vector<int> &y) {
  auto ans = multiply(x, y);
  int carry = 0;
  int pos = 0;
  while (pos < int(ans.size())) {
    carry += ans[pos];
    ans[pos] = carry % 10;
    carry /= 10;
    if (carry && pos + 1 == int(ans.size())) ans.push_back(0);
    pos++;
  }
  return ans;
}
vector<int> pow3(long long exp) {
  vector<int> result = {1};
  vector<int> base = {3};
  while (exp) {
    if (exp & 1) result = mul(result, base);
    exp >>= 1;
    base = mul(base, base);
  }
  reverse(result.begin(), result.end());
  return result;
}
bool low(vector<int> &a, vector<int> &b) {
  if (int(a.size()) != int(b.size())) return int(a.size()) < int(b.size());
  for (int i = 0, ThxDem = int(a.size()); i < ThxDem; ++i)
    if (b[i] != a[i]) return a[i] < b[i];
  return 0;
}
void mul3(vector<int> &ans) {
  int carry = 0;
  int pos = 0;
  reverse(ans.begin(), ans.end());
  while (pos < int(ans.size())) {
    carry += ans[pos] * 3;
    ans[pos] = carry % 10;
    carry /= 10;
    if (carry && pos + 1 == int(ans.size())) ans.push_back(0);
    pos++;
  }
  reverse(ans.begin(), ans.end());
}
void sum(vector<int> &a, int asd) {
  int carry = asd;
  for (int i = int(a.size()) - 1; i >= 0; i--) {
    if (!carry) break;
    carry += a[i];
    a[i] = carry % 10;
    carry /= 10;
  }
}
vector<int> div2(vector<int> a) {
  vector<int> ans = a;
  int carry = 0;
  for (int i = 0, ThxDem = int(ans.size()); i < ThxDem; ++i) {
    carry = (10 * carry) + ans[i];
    ans[i] = carry / 2;
    carry = carry & 1;
  }
  if (carry) sum(ans, 1);
  if (int(ans.size()) > 1 && ans[0] == 0)
    ans = vector<int>(ans.begin() + 1, ans.end());
  return ans;
}
void print(vector<int> &a) {
  for (auto x : a) cout << x;
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  if (s == "1") cout << "1\n", exit(0);
  vector<int> n;
  for (auto x : s) n.push_back(x - '0');
  div2(n);
  auto n2 = div2(n);
  auto n4 = div2(n2);
  double lg10 = log(10) / log(3);
  int k = ceil((int(s.size()) - 1) * lg10);
  int mx = max(0, k - 4);
  auto ans = pow3(mx);
  while (low(ans, n4)) mul3(ans), mx++;
  int x4 = mx;
  while (low(ans, n2)) mul3(ans), mx++;
  int x2 = mx;
  while (low(ans, n)) mul3(ans), mx++;
  int x = mx;
  x = 3 * x;
  x2 = 3 * x2 + 2;
  x4 = 3 * x4 + 4;
  cout << min({x, x2, x4}) << "\n";
}
