#include <bits/stdc++.h>
using namespace std;
int n, ans;
int dfs(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 1) return a - 1;
  if (a < 1 || b < 1) return 100;
  return dfs(a % b, b) + a / b;
}
int main() {
  ans = 100;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) ans = min(ans, dfs(n, i));
  cout << ans << endl;
}
