#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
int gcd(int a, int b) {
  if (a == 1) return b - 1;
  if (b % a == 0) return INF;
  return b / a + gcd(b % a, a);
}
int main() {
  int n, ans, t;
  cin >> n;
  if (n == 1) {
    cout << "0";
    return 0;
  }
  for (int i = 1; i < n; i++) {
    t = gcd(n, i);
    if (t < ans) ans = t;
  }
  cout << ans;
  return 0;
}
