#include <bits/stdc++.h>
using namespace std;
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
void solve() {
  long long int n;
  cin >> n;
  long long int ans = 1e18;
  for (long long int i = (1); i <= (n); ++i) {
    long long int x = n, y = i;
    long long int cnt = 0;
    while (x != y) {
      if (y > x) swap(x, y);
      if (y == 0) break;
      long long int req = (x - 1) / y;
      x = x - (req)*y;
      cnt += req;
    }
    if (x == y && x == 1) ans = min(ans, cnt);
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  t = 1;
  for (long long int i = (1); i <= (t); ++i) {
    solve();
  }
}
