#include <bits/stdc++.h>
using namespace std;
const int INF32M = 0x3f3f3f3f;
const long long INF64M = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e5 + 5;
int cnt;
void dfs(int x, int y) {
  if (y == 0) {
    cnt = INF32M;
    return;
  }
  if (y == 1) {
    cnt += x - 1;
    return;
  }
  cnt += x / y;
  dfs(y, x % y);
}
int main() {
  ios::sync_with_stdio(false);
  int n, ans, minn = 1e9;
  cin >> n;
  if (n == 1) return puts("0"), 0;
  for (int i = 1; i <= n - 1; i++) {
    cnt = 0;
    dfs(n, i);
    if (cnt < minn) minn = cnt;
  }
  cout << minn << endl;
  return 0;
}
