#include <bits/stdc++.h>
using namespace std;
long long int fun(long long int a, long long int b) {
  if (b == 0) {
    return 1000000000;
  } else if (b == 1) {
    return a - 1;
  }
  return fun(b, a % b) + a / b;
}
int main() {
  long long int t, n, d = 0, u, u1, k = 0, l = 0, mid, x = 0, i = 0, m, f = 0,
                      j = 0, r, c = 0, j1 = 0, s1 = 0, sum = 0, s = 0,
                      mx1 = 1000000000000000000, mxa = -2000000000,
                      mx = 2000000000, mx11 = 2000000000;
  cin >> n;
  for (i = 1; i <= n; i++) {
    mx = min(mx, fun(n, i));
  }
  cout << mx << endl;
  return 0;
}
