#include <bits/stdc++.h>
using namespace std;
int gcdSteps(int A, int B) {
  int result = 0;
  while (B) {
    result += A / B;
    A %= B;
    swap(A, B);
  }
  return result;
}
int gcd(int A, int B) {
  while (B) {
    A %= B;
    swap(A, B);
  }
  return A;
}
int main() {
  int n;
  cin >> n;
  int result = n - 1;
  for (int i = 1; i < n; i++) {
    if (gcd(n, i) == 1) result = min(result, gcdSteps(n, i) - 1);
  }
  cout << result;
  return 0;
}
