#include <bits/stdc++.h>
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
using namespace std;
const int N = 1e6 + 5;
int n;
int a, b;
int cnt;
int f[N];
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int calculate(int x, int y) {
  int cnt = 0;
  while (x != 1 || y != 1) {
    if (x > y) {
      swap(x, y);
    }
    int temp = y - x;
    int num = temp / x;
    cnt += num;
    y -= num * x;
    if (y > x) {
      y -= x;
      cnt++;
    }
  }
  return cnt;
}
int main() {
  scanf("%d", &n);
  if (n == 1) {
    puts("0");
  } else {
    for (int i = 1; i < n; i++) {
      if (gcd(i, n) == 1) {
        f[++cnt] = i;
      }
    }
    int minn = inf;
    for (int i = 1; i <= cnt; i++) {
      minn = min(minn, calculate(f[i], n));
    }
    printf("%d\n", minn);
  }
  return 0;
}
