#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 1e9;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int r = 0, a = n, b = i;
    while (b > 0) {
      r += a / b;
      a %= b;
      swap(a, b);
    }
    if (a == 1) {
      c = min(c, r - 1);
    }
  }
  cout << c << endl;
}
