#include <bits/stdc++.h>
using namespace std;
const int INF = 1e6 + 1;
int find(int a, int b) {
  if (b == 0) return INF;
  if (b == 1)
    return a - 1;
  else
    return find(b, a % b) + a / b;
}
int main() {
  int n;
  while (cin >> n) {
    if (n == 1) {
      cout << 0 << endl;
      continue;
    }
    int MIN = INF;
    for (int i = 1; i <= n / 2; i++) {
      int tem = find(n, i);
      if (MIN > tem) MIN = tem;
    }
    cout << MIN << endl;
  }
  return 0;
}
