#include <bits/stdc++.h>
using namespace std;
int el(int a, int b) {
  int ans = 0, tmp;
  while (a != 1 || b != 1) {
    if (b == 0)
      return 1000000000;
    else if (b == 1) {
      ans += a - 1;
      break;
    }
    tmp = a / b;
    a -= tmp * b;
    ans += tmp;
    if (a < b) swap(a, b);
  }
  return ans;
}
int main() {
  int n, ans = 1000000000;
  scanf("%d", &n);
  for (int i = n; i >= 1; --i) ans = min(el(n, i), ans);
  printf("%d\n", ans);
  return 0;
}
