#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000007);
const int INF((1 << 30) - 1);
const int MAXN();
int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) {
    printf("0");
    return 0;
  }
  int ans = INF;
  for (int i = 1; i <= n - 1; i++) {
    int a = n, b = i, cnt = 0;
    while (b != 0) {
      cnt += (a / b);
      a %= b;
      swap(a, b);
    }
    if (a == 1) ans = min(ans, cnt);
  }
  printf("%d", ans - 1);
}
