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