#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > cur, next;
int ans = 10000000;
int go(pair<int, int> a) {
  int step = 0;
  while (a.first != 1 || a.second != 1) {
    ++step;
    if (step > ans) break;
    if (step > 2000000) break;
    if (a.first > a.second) swap(a.first, a.second);
    a.second -= a.first;
  }
  ans = min(ans, step);
  return step;
}
int gcd(int a, int b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << '\n';
    return 0;
  }
  for (int i = 1; i < n; ++i)
    if (gcd(i, n) == 1) go(pair<int, int>(i, n));
  cout << ans << '\n';
  return 0;
}
