import sys
def gcd(a,b):
    if(b==0):
        return sys.maxsize
    if(b==1):
        return a-1
    return (int)(a/b)+gcd(b,a%b)
n=(int)(input())
record=sys.maxsize
if(n==1):
    print(0,end="")
else:
    for i in range(0,n):
        record=min(gcd(n,i),record)
    print(record,end="")


e58276fd5fc90b835b61762a8de636860f173d4a
<mask token>


def gcd(a, b):
    if b == 0:
        return sys.maxsize
    if b == 1:
        return a - 1
    return int(a / b) + gcd(b, a % b)


<mask token>

<mask token>


def gcd(a, b):
    if b == 0:
        return sys.maxsize
    if b == 1:
        return a - 1
    return int(a / b) + gcd(b, a % b)


<mask token>
if n == 1:
    print(0, end='')
else:
    for i in range(0, n):
        record = min(gcd(n, i), record)
    print(record, end='')

<mask token>


def gcd(a, b):
    if b == 0:
        return sys.maxsize
    if b == 1:
        return a - 1
    return int(a / b) + gcd(b, a % b)


n = int(input())
record = sys.maxsize
if n == 1:
    print(0, end='')
else:
    for i in range(0, n):
        record = min(gcd(n, i), record)
    print(record, end='')

import sys


def gcd(a, b):
    if b == 0:
        return sys.maxsize
    if b == 1:
        return a - 1
    return int(a / b) + gcd(b, a % b)


n = int(input())
record = sys.maxsize
if n == 1:
    print(0, end='')
else:
    for i in range(0, n):
        record = min(gcd(n, i), record)
    print(record, end='')

import sys
def gcd(a,b):
    if(b==0):
        return sys.maxsize
    if(b==1):
        return a-1
    return (int)(a/b)+gcd(b,a%b)
n=(int)(input())
record=sys.maxsize
if(n==1):
    print(0,end="")
else:
    for i in range(0,n):
        record=min(gcd(n,i),record)
    print(record,end="")

