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