#include <bits/stdc++.h>
using namespace std;
int inf = (1 << 30);
int best(int n, int m) {
  return m == 0 ? inf : (m == 1 ? n - 1 : best(m, n % m) + n / m);
}
int main() {
  int n, r;
  cin >> n;
  r = n - 1;
  for (int m = 1; m < n; m++) r = min(r, best(n, m));
  cout << r << endl;
  return 0;
}
