#include <bits/stdc++.h>
using namespace std;
int k;
int pair_len(int a, int b) {
  if (b == 1) return (a / b - 1);
  if (a == b) return 1000001;
  int x = a / b;
  if (a % b == 0) x--;
  int z = a - x * b;
  return x + pair_len(max(z, b), min(z, b));
}
int main() {
  scanf("%d", &k);
  int best = 1000001;
  for (int i = 1; i <= k; i++) best = min(best, pair_len(k, i));
  printf("%d\n", best);
  return 0;
}
