#include <bits/stdc++.h>
using namespace std;
int n, ans = 2000000000;
int gcd(int a, int b) {
  if (b == 0 or a == 0) return 2000000000;
  if (b == 1) return a - 1;
  if (a == 1)
    return b - 1;
  else
    return a / b + gcd(b, a % b);
}
int a, b;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n; i++) {
    a = n, b = i;
    ans = min(ans, gcd(a, b));
  }
  printf("%d", ans);
  return 0;
}
