#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int gao(int a, int b) {
  int h = 0;
  while (a > 1 || b > 1) {
    if (a < b) swap(a, b);
    if (b > 1) {
      h += a / b;
      a %= b;
    } else
      return h + a - 1;
  }
  return h;
}
int main() {
  int n, ans = 10000000;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  };
  if (n == 2) {
    cout << 1 << endl;
    return 0;
  };
  for (int i = 1; i < n; ++i)
    if (gcd(i, n) == 1) {
      ans = min(gao(n, i), ans);
    }
  {
    cout << ans << endl;
    return 0;
  };
  return 0;
}
