#include <bits/stdc++.h>
int gcd(int a, int b, int &counter) {
  if (b == 0) return a;
  counter += a / b;
  return gcd(b, a % b, counter);
}
int main() {
  int n;
  int minn = 1000000;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int tempCounter = 0;
    if (gcd(n, i, tempCounter) == 1 && tempCounter < minn) minn = tempCounter;
  }
  if (n == 1)
    minn = 0;
  else
    minn--;
  printf("%d\n", minn);
  return 0;
}
