#include <bits/stdc++.h>
using namespace std;
int n;
int ans = 0;
int solve(int h, int a, int b) {
  if (b == 0) return n;
  if (b == 1) return h + a - 1;
  if (a == b) return n;
  return solve(h + a / b, b, a % b);
}
int main() {
  int i, j, k, r, w;
  while (scanf("%d", &n) != EOF) {
    ans = n;
    int a = 1, b = 1;
    for (i = 1; i <= n; i++) {
      ans = min(ans, solve(0, n, i));
    }
    printf("%d\n", ans);
  }
  return 0;
}
