#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 10;
const long long maxn = 1e5 + 10;
const long long mod = 1e9 + 7;
long long gcc(long long a, long long b) {
  if (b == 1) return a - 1;
  if (a % b == 0) return inf;
  return a / b + gcc(b, a % b);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  if (n == 1) return cout << 0 << endl, 0;
  long long ans = inf;
  for (long long i = 1; i < n; i++) ans = min(ans, gcc(n, i));
  cout << ans << endl;
  return 0;
}
