#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
int dfs(int x, int y) {
  if (y == 1) return x - 1;
  if (y == 0) return 1000000;
  return x / y + dfs(y, x % y);
}
int main() {
  int n, ans;
  cin >> n;
  ans = n - 1;
  for (int m = 1; m < n; m++) ans = min(ans, dfs(n, m));
  cout << ans << endl;
  return 0;
}
