#include <bits/stdc++.h>
using namespace std;
pair<int, bool> gcd(int a, int b) {
  if (b == 1) return make_pair(a - 1, 1);
  if (b == 0) return make_pair(0, 0);
  pair<int, bool> m = gcd(b, a % b);
  return make_pair((m.first + a / b), m.second);
}
int main() {
  int n;
  cin >> n;
  int mn = n - 1;
  for (int i = 2; i <= n; i++) {
    pair<int, bool> a = gcd(i, n);
    if (mn > a.first && a.second) {
      mn = a.first;
    }
  }
  cout << mn;
  return 0;
}
