#include <bits/stdc++.h>
using namespace std;
long n;
long k = numeric_limits<long>::max();
bool flag = false;
int gcd(long a, long b) {
  if (a == 0 || b == 0) return 0;
  if (a < b) swap(a, b);
  long r;
  do {
    r = a % b;
    a = b;
    b = r;
  } while (r != 0);
  return a;
}
void dfs(long a, long b, long cnt) {
  if (a == 1 && b == 1) {
    k = min(k, cnt);
    flag = true;
    return;
  }
  if (a > b)
    dfs(a - b, b, cnt + 1);
  else
    dfs(a, b - a, cnt + 1);
}
void solve() {
  cin >> n;
  for (long i = (1); i < (n); i++) {
    if (gcd(i, n) == 1) {
      dfs(i, n, 0);
    }
  }
  long ans = (flag == true) ? k : 0;
  cout << ans << endl;
}
int main(int argc, char *argv[]) {
  solve();
  return 0;
}
