#include <bits/stdc++.h>
using namespace std;
int N, cnt = int(1e6), i;
int gcd(int a, int b) {
  if (b == 0) return int(1e6);
  if (b == 1)
    return a - 1;
  else
    return gcd(b, a % b) + a / b;
}
int main() {
  cin >> N;
  for (i = 1; i <= N; ++i) cnt = (cnt > gcd(N, i)) ? (gcd(N, i)) : (cnt);
  cout << cnt << endl;
  return 0;
}
