#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
void we_r_done() {
  cout << "NO";
  exit(0);
}
void debug(string mssg) {
  cout << mssg;
  exit(0);
}
using minHeap = priority_queue<int, vector<int>, greater<int> >;
inline int addmod(int x, int y) {
  return (x % 1000000007 + y % 1000000007) % 1000000007;
}
inline int submod(int x, int y) {
  return (x % 1000000007 - y % 1000000007 + 1000000007) % 1000000007;
}
inline int mulmod(int x, int y) {
  return (x % 1000000007 * 1LL * y % 1000000007) % 1000000007;
}
int n;
int ans;
int fun(int a, int b) {
  if (b == 0) return 1e9;
  if (b == 1) return a - 1;
  return fun(b, a % b) + a / b;
}
int main() {
  scanf("%d", &n);
  ans = n - 1;
  for (int i = 1; i <= n; i++) ans = min(ans, fun(n, i));
  cout << ans;
  return 0;
}
