#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m;
int MDC(int a, int b) {
  if (b == 0) return a;
  return MDC(b, a % b);
}
int Calc(int a, int b) {
  int c, d;
  if (a == 0 || b == 0) return 0;
  if (b > a) {
    d = b;
    b = a;
    a = d;
  }
  d = a / b;
  return (d + Calc(b, a % b));
}
int main() {
  cin >> n;
  m = 1000000000;
  for (i = 1; i <= n / 2; i++) {
    if (MDC(i, n - i) == 1) {
      m = min(m, Calc(n - i, i));
    }
  }
  if (n == 1)
    cout << '0' << endl;
  else
    cout << m << endl;
  return 0;
}
