#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const int mod = 1e9 + 9;
const int maxn = 3e5 + 7;
const int lim = 800667;
int tmp;
void dfs(int a, int b) {
  if (b == 0) {
    tmp = INF;
    return;
  } else if (b == 1) {
    tmp += a - 1;
    return;
  }
  tmp += a / b;
  dfs(b, a % b);
}
int main() {
  int n;
  scanf("%d", &n);
  int res = n - 1;
  for (int i = 1; i < n; ++i) {
    tmp = 0;
    dfs(n, i);
    res = min(res, tmp);
  }
  printf("%d\n", res);
  return 0;
}
