#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();
  return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
  if (!w) return 1 % mod;
  if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}
template <typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template <typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}
template <typename T>
void make_unique(vector<T>& vec) {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
template <typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}
template <typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}
void precalc() {}
const int LBase = 4;
const int Base = 10000;
struct BigInt {
  vector<int> a;
  BigInt() {}
  BigInt(string s) {
    reverse(s.begin(), s.end());
    for (int i = 0; i < s.length(); i += LBase) {
      int en = min((int)s.length(), i + LBase);
      int cur = 0;
      for (int j = en - 1; j >= i; --j) {
        cur = cur * 10 + s[j] - '0';
      }
      a.push_back(cur);
    }
  }
  void norm() {
    int carry = 0;
    for (int i = 0; i < a.size() || carry > 0; ++i) {
      if (i == a.size()) {
        a.push_back(0);
      }
      a[i] += carry;
      carry = a[i] / Base;
      a[i] -= carry * Base;
    }
    while (a.size() > 0 && a.back() == 0) {
      a.pop_back();
    }
  }
  bool operator<(const BigInt& ot) const {
    if (a.size() != ot.a.size()) {
      return a.size() < ot.a.size();
    }
    for (int i = 0; i < a.size(); ++i) {
      int q = a[a.size() - 1 - i], w = ot.a[a.size() - 1 - i];
      if (q != w) {
        return q < w;
      }
    }
    return false;
  }
  BigInt operator*(int c) const {
    BigInt res = *this;
    for (int& x : res.a) {
      x *= c;
    }
    res.norm();
    return res;
  }
};
const int L = 20;
const int N = 1 << L;
bool fft_initialized = false;
struct cd {
  double x, y;
  cd operator*(const cd& other) {
    return {x * other.x - y * other.y, x * other.y + y * other.x};
  }
  cd operator+(const cd& other) { return {x + other.x, y + other.y}; }
  cd operator-(const cd& other) { return {x - other.x, y - other.y}; }
  double real() { return x; }
  double imag() { return y; }
};
inline cd conj(const cd& x) { return {x.x, -x.y}; }
cd polar(double x, double y) {
  auto p = std::polar(x, y);
  return {p.real(), p.imag()};
}
using base = cd;
using Poly = vector<double>;
const double pi = acosl(-1);
base angles[N];
int bitrev[N];
const double eps = 1e-7;
inline bool eq(double x, double y) { return abs(x - y) < eps; }
void fft_init() {
  for (int n = 1; n < N; n *= 2) {
    auto w = angles + n;
    for (int i = 0; i < n; ++i) {
      w[i] = polar(1.0, pi * i / n);
    }
  }
}
template <bool inverse>
void fft(base* y, base* x, int n, int k = 1) {
  if (n == 1) {
    *y = *x;
  } else {
    n /= 2;
    fft<inverse>(y, x, n, k * 2);
    fft<inverse>(y + n, x + k, n, k * 2);
    for (int i = 0, j = n; i < n; ++i, ++j) {
      auto q = y[j] * (inverse ? conj(angles[j]) : angles[j]);
      y[j] = y[i] - q;
      y[i] = y[i] + q;
    }
  }
}
void fft(vector<base>& a, bool inverse = false) {
  int n = (int)a.size();
  static base b[1 << 20];
  for (int i = 0; i < n; ++i) {
    b[i] = a[i];
  }
  if (inverse) {
    fft<true>(a.data(), b, n);
    auto rev = 1.0 / n;
    for (auto& x : a) {
      x = {x.real() * rev, x.imag() * rev};
    }
  } else {
    fft<false>(a.data(), b, n);
  }
}
Poly multiply(Poly a, Poly b) {
  int n = 1;
  while (n < (int)a.size() || n < (int)b.size()) {
    n *= 2;
  }
  vector<base> ar(n + n), br(n + n);
  for (int i = 0; i < (int)a.size(); ++i) {
    ar[i] = {(double)a[i], 0};
  }
  for (int i = 0; i < (int)b.size(); ++i) {
    br[i] = {(double)b[i], 0};
  }
  fft(ar);
  fft(br);
  for (int i = 0; i < n + n; ++i) {
    ar[i] = ar[i] * br[i];
  }
  fft(ar, true);
  while (!ar.empty() && eq(ar.back().real(), 0)) {
    ar.pop_back();
  }
  a.resize(ar.size());
  for (int i = 0; i < (int)a.size(); ++i) {
    a[i] = ar[i].real();
  }
  return a;
}
BigInt multiply(const BigInt& a, const BigInt& b) {
  vector<double> A(a.a.begin(), a.a.end()), B(b.a.begin(), b.a.end());
  auto C = multiply(A, B);
  BigInt res;
  res.a.resize(C.size());
  li carry = 0;
  for (int i = 0; i < C.size() || carry; ++i) {
    if (i < C.size()) {
      carry += (li)round(C[i]);
    }
    if (i == res.a.size()) {
      res.a.push_back(0);
    }
    res.a[i] = carry % Base;
    carry /= Base;
  }
  res.norm();
  return res;
}
BigInt get_power(BigInt cur, int what) {
  if (what == 0) {
    return BigInt("1");
  }
  cur = get_power(cur, what / 2);
  cur = multiply(cur, cur);
  if (what & 1) {
    cur = cur * 3;
  }
  return cur;
}
void solve(bool read) {
  string s;
  if (read) {
    cin >> s;
  } else {
    s = string(1500000, '9');
    for (int i = 1; i < s.length(); ++i) {
      s[i] = (char)('0' + rand() % 10);
    }
  }
  if (s == "1") {
    cout << 1 << "\n";
    return;
  }
  BigInt num(s);
  double log_appr = ((int)s.length() - 1);
  log_appr = log_appr * log(10) / log(3);
  int b = max((int)(log_appr - 5), 0);
  if (b % 2 == 1) --b;
  fft_init();
  int need_b = b;
  BigInt three;
  three.a = vector<int>(1, 3);
  BigInt res = get_power(three, b);
  int ans = (int)1e9;
  auto relax = [&](int mult, int a) {
    auto cur_res = res * mult;
    int cur_ans = 3 * b + a * 2;
    while (cur_res < num) {
      cur_res = cur_res * 3;
      cur_ans += 3;
    }
    ans = min(ans, cur_ans);
  };
  relax(1, 0);
  relax(2, 1);
  relax(4, 2);
  cout << ans << "\n";
}
