#include <bits/stdc++.h>
using namespace std;
const int N = 300200;
const long long MOD = 1e9 + 7;
int d1[1001][1001], d2[200][200][2];
long long a[N], a1[N], a2[N], a3[N];
bool used[N];
int sum = 0, k = 0, t = 0, cnt = 0;
int foo(int x, int y) {
  if (y == 1) return x - 1;
  if (y == 0) return MOD;
  return x / y + foo(y, x % y);
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, c, d, e;
  cin >> n;
  cnt = MOD;
  for (int i = 1; i < n; i++) {
    cnt = min(cnt, foo(n, i));
  }
  if (n == 1) cnt = 0;
  cout << cnt;
}
