#include <bits/stdc++.h>
using namespace std;
const long long N = 5e18;
const int M = 1e9 + 7;
const double eps = 1e-9;
long long gcd(long long a, long long b, long long &tot) {
  if (b == 0) return a;
  if (b == 1) {
    tot += a - 1;
    return 1;
  }
  tot += a / b;
  return gcd(b, a % b, tot);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  if (n == 1) return cout << 0 << endl, 0;
  long long mn = INT_MAX;
  for (int i = 1; i < n; ++i) {
    long long tot = 0;
    long long g = gcd(n, i, tot);
    if (g == 1) {
      mn = min(mn, tot);
    }
  }
  cout << mn << endl;
}
