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