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