#include <bits/stdc++.h>
using namespace std;
int n, m;
int abc(int x, int y, int z) {
  if (x == 1 && y == 1) return z;
  if (x == y) return 10000000;
  if (x < y)
    return abc(x, (y - 1) % x + 1, z + (y - 1) / x);
  else
    return abc(y, (x - 1) % y + 1, z + (x - 1) / y);
}
int main() {
  scanf("%d", &n);
  m = abc(1, n, 0);
  for (int i = 2; i <= n; i++) m = min(m, abc(i, n, 0));
  printf("%d\n", m);
  return 0;
}
