#include <bits/stdc++.h>
template <class T>
inline void checkmin(T& a, T b) {
  if (b < a) a = b;
}
int d(int a, int b) {
  if (b % a == 0 && a != 1) return (1LL << 29);
  if (b % a == 0) return b - 1;
  int ct = ((b - a) / a) + 1;
  return d(b - (ct * a), a) + ct;
}
int main() {
  int n, m = (1LL << 29);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) checkmin(m, d(i + 1, n));
  printf("%d\n", m);
  return 0;
}
