#include <bits/stdc++.h>
using namespace std;
int n, ans = 1e9;
int gcd(int a, int b) {
  if (b == 1) return a - 1;
  if (a == b) return 1e9;
  if (a == 0 || b == 0) return 1e9;
  return gcd(b, a % b) + a / b;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) ans = min(ans, gcd(i, n));
  printf("%d\n", ans);
  return 0;
}
