#include <bits/stdc++.h>
using namespace std;
long long num(long long ch, long long n) {
  if (ch > n) return num(n, ch);
  if (ch == 1) return n;
  if (n % ch == 0) return 1000009;
  long long cnt = (n - (n % ch)) / ch;
  return cnt + num(n % ch, ch);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long min = n + 20;
  for (int i = 1; i <= n; i++) {
    long long ch = num(i, n);
    min = (min < ch ? min : ch);
  }
  cout << min - 1 << '\n';
}
