import java.io.*;
import java.util.*;
import java.math.*;
public class Main {

    public static void main(String[] args) {
        Scanner in=new Scanner(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        int n=in.nextInt();
        int ans=1<<16;
        for(int i=1;i<=n/2+1;i++)
        {
            int a=i,b=n-i,cnt=0;
            while(a>1)
            {
                int temp=b%a;
                cnt+=b/a;
                b=a;
                a=temp;
                if(a>b)
                {
                    int tmp=b;
                    b=a;
                    a=tmp;
                }
            }
            if(a==0)continue;
            cnt+=b;
            ans=Math.min(ans,cnt);
        }
        out.print(ans);
        out.close();
    }

}

import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}

					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: " + (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
		in.close();
	}

	/***************************************************************
	 * Solution
	 **************************************************************/

	final int INF = Integer.MAX_VALUE / 2;

	void solve() throws IOException  {
		int n = nextInt();
		int ans = INF;
		for (int x = 1; x <= n; x++) {
			ans = min(ans, solve(x, n));
		}
		solve(2, n);
		out.println(ans);
	}

	int solve(int a, int b) {
		int ret = -1;
		while (a > 0 && b > 0) {
			if (a > b) {
				ret += a / b;
				a %= b;
			} else {
				ret += b / a;
				b %= a;
			}
		}
		return a + b == 1 ? ret : INF;
	}

	/***************************************************************
	 * Input
	 **************************************************************/
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nextIntArray(int size) throws IOException {
		int[] ret = new int [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextInt();
		return ret;
	}

	long[] nextLongArray(int size) throws IOException {
		long[] ret = new long [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextLong();
		return ret;
	}

	double[] nextDoubleArray(int size) throws IOException {
		double[] ret = new double [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextDouble();
		return ret;
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}

	/***************************************************************
	 * Output
	 **************************************************************/
	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}

	/***************************************************************
	 * Utility
	 **************************************************************/
	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() >> 20) + "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	static void checkMemory() {
		System.err.println(memoryStatus());
	}

	static long prevTimeStamp = Long.MIN_VALUE;

	static void updateTimer() {
		prevTimeStamp = System.currentTimeMillis();
	}

	static long elapsedTime() {
		return (System.currentTimeMillis() - prevTimeStamp);
	}

	static void checkTimer() {
		System.err.println(elapsedTime() + " ms");
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TestingRound3_B {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        if(n==1){
            System.out.println(0);
            return;
        }
        int res = 10000000;
        for (int i = 1; i < n; i++) {
            int a = i;
            int b = n;
            int curr = 0;
            while(a>1 || b>1){
               if(a==b)
                   break;
               if(a==0 || b==0)
                   break;
               if(a>b){
                   a = a-b;
               }else
                   b = b-a;
               curr++;
            //   System.out.println(a+" "+b+" "+i+" "+curr);
            }
            if(a==1 && b==1)
            res = Math.min(res, curr);
        }
        System.out.println(res);
    }
}

import java.util.Scanner;

public class PairsofNumbers {

    public static int get(int a, int b)
    {
        int cnt = 0;
        while(true)
        {
            if(a == 1 && b == 1)
                return cnt;
            if(a < 1 || b < 1)
                return -1;

            if(a < b)
                b = b-a;
            else
                a = a-b;
            cnt++;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), limit = (N+1)/2;

        int min = Integer.MAX_VALUE, k;
        for(int i = 1; i <= limit; i++)
        {
            k = get(i, N);
            if(k != -1)
                min = Math.min(min, get(i, N));
        }

        System.out.println(min);
    }
}

/*
 * Author Ayub Subhaniya
 * Institute DA-IICT
 */

import java.io.*;
import java.math.*;
import java.util.*;

public class Driver {

	InputStream in;
	PrintWriter out;

	int steps(int a,int b)
	{
		if (a==1&&b==1)
			return 0;

		int s=0;
		while (true)
		{
			if (a==1&&b==1)
				return s;
			if (a<=0||b<=0)
				return (int)1e6;

			if (a>=b)
				a-=b;
			else
				b-=a;
			s++;
		}
	}

	void solve() {
		int n=ni();
		if (n==1)
		{
			out.println(0);
			return;
		}

		int steps=(int)1e7;
		for (int i=1;i<=n;i++)
			steps=Math.min(steps, steps(n,i));

		out.println(steps);
	}

	class Pair implements Comparable<Pair> {
		int x;
		int y;
		int i;
		Pair(int a, int b,int c) {
			x = a;
			y = b;
			i=c;
		}

		@Override
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return x == other.x && y == other.y;
		}

		public String toString() {
			return x + " " + y;
		}

		@Override
		public int compareTo(Pair o) {
			if (x == o.x)
				return Integer.compare(y, o.y);
			else
				return Integer.compare(x, o.x);
		}

		@Override
		public int hashCode() {
			return Objects.hash(x, y);
		}
	}

	void run() throws Exception {
		String INPUT = "C:/Users/ayubs/Desktop/input.txt";
		in = oj ? System.in : new FileInputStream(INPUT);
		out = new PrintWriter(System.out);

			long s = System.currentTimeMillis();
			solve();
			out.flush();
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Driver().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean inSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && inSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(inSpaceChar(b))) { // when nextLine, (inSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(inSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {

	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();

        int min = Integer.MAX_VALUE;
        if(n==1)
        {
            out.println(0);
            return;
        }
        for(int i=1;i<n;i++){
            min = Math.min(min,cal(n,i));
        }
        out.println(min);
    }

    int cal(int a,int b){
        if(b==1) return a-1;
        if(a%b==0) return 1000000;
        return a/b + cal(b,a%b);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt(){
        return Integer.parseInt(next());
    }

    }

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=Integer.MAX_VALUE;
        for (int i = 1; i <= input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            //print(step);
            if(b==1){
                //print(step);
                out=Math.min(out,step);
            }
        }
        print (out-1);
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=Integer.MAX_VALUE;

        for (int i = 1; i <= input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            //print(step);
            if(b==1){
                //print(step + " "+b);
                out=Math.min(out,step);
            }
        }
        print (out-1);
    }
}

import java.io.*;
import java.util.List;
import java.util.StringTokenizer;

public class Cbr {

    public static void main(String[] args) throws IOException {
        new Cbr().run();
    }

    private void run() throws IOException {
        int n = nextInt();
        if (n == 1)
            pw.println(0);
        else {
            int r = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int a = n, b = i;
                int k = 0;
                while (a > 0 && b > 0) {
                    if (b == 1) {
                        k += a - 1;
                        a = 1;
                    }
                    else {
                        k += a / b;
                        int t = b;
                        b = a % b;
                        a = t;
                    }
                    if (a == 1 && b == 1)
                        break;
                }
                if (a == 1 && b == 1 && k < r)
                    r = k;
            }
            pw.println(r);
        }
        pw.flush();
    }

    private StringTokenizer st;
    private BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
    private PrintWriter pw = new PrintWriter(System.out);

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

}

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class B {
    static int dfs(int a, int b, int n) {
        int res = 1;
//      if(a > b) { int t = a; a = b; b = t; }
        while(b > 1 && res < n) {
            b -= a;
            if(a > b) { int t = a; a = b; b = t; }
            res++;
        }
        return b == 1 ? res : Integer.MAX_VALUE;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        int res = n == 1 ? 0 : Integer.MAX_VALUE;
        for(int i = 1; i <= n/2; i++) {
            res = Math.min(res, dfs(i, n-i, res));
        }
        System.out.println(res);
    }
}

import java.io.*;
import java.util.*;

public class B {

	public B () throws IOException {
		int N = sc.nextInt();
		solve(N);
	}

	public void solve (int N) {
		t = millis();

		if (N == 1)
			print(0);

		long res = Integer.MAX_VALUE;
		for (int M = 1; M < N; ++M) {
			int K = 0, m = M, n = N;
			while (m > 1 && n > 1) {
				if (m >= n)
					m -= n;
				else
					n -= m;
				++K;
			}
			if (m > 0 && n > 0) {
				K += Math.max(m, n) - 1;
				res = Math.min(res, K);
			}
		}
		print(res);
	}

	////////////////////////////////////////////////////////////////////////////////////

	static Scanner sc;
	static long t;

	static void print (Object o) {
		System.out.println(o);
		System.exit(0);
	}

	static void run () throws IOException {
		sc = new Scanner(System.in);
		new B();
		print ((millis() - t) / 1000.0);
	}

	public static void main(String[] args) throws IOException {
		run();
	}

	static long millis() {
		return System.currentTimeMillis();
	}
}

import java.util.*;
import java.text.*;
import java.math.*;
import java.io.*;

public class ololo {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n=in.nextInt(),best=1000000000;
		for (int i=1;i<=n/2;i++) {
			int a=i,b=n,cnt=0;
			boolean f=true;
			while ((a!=1 || b!=1) && f) {
				if (a==b) f=false;
				if (a>b) a-=b;
				else b-=a;
				cnt++;
			}
			if (f) best=Math.min(cnt, best);
		}
		out.println(n==1?0:best);
		out.flush();
	}
}

import java.util.*;
import java.text.*;
import java.math.*;
import java.io.*;

public class ololo {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n=in.nextInt(),best=1000000000;
		for (int i=1;i<n;i++) {
			int a=i,b=n,cnt=0;
			boolean f=true;
			while ((a!=1 || b!=1) && f) {
				if (a==b) f=false;
				if (a>b) a-=b;
				else b-=a;
				cnt++;
			}
			if (f) best=Math.min(cnt, best);
		}
		out.println(n==1?0:best);
		out.flush();
	}
}

import java.io.*;
import java.lang.Math;
import java.util.*;

public class Main
{
	public BufferedReader in;
	public PrintStream out;

	public int calc(int a, int b)
	{
		if (a<b)
		{
			return calc(b,a);
		}

		if (b==0)
		{
			return 10000001;
		}

		if (b==1)
		{
			return a-b;
		}

		return  calc(b, a% b) + a/b;
	}

	public void test()
	{
		int n = readInt();
		int min = n-1;
		int c;

		for (int k=2; k<n; k++)
		{
			c = calc(n,k);
			if ((c>=0)&&(c<min))
			{
				min = c;
			}
		}

		out.println(min);
	}

	public void run()
	{
		try
		{
			in = new BufferedReader(new InputStreamReader(System.in));
			out = System.out;

			//in = new BufferedReader(new FileReader("in.txt"));
			//out = new PrintStream(new File("out.txt"));

		}
		catch (Exception e)
		{
			return;
		}

		//while (true)
		{
			//int t = readInt(); for (int i=0; i<t; i++)
			{
				test();
			}
		}
	}

	public static void main(String args[])
	{
		new Main().run();
	}

	private StringTokenizer tokenizer = null;

	public int readInt()
	{
        return Integer.parseInt(readToken());
    }

    public long readLong()
	{
        return Long.parseLong(readToken());
    }

    public double readDouble()
	{
        return Double.parseDouble(readToken());
    }

	public String readLn()
	{
		try
		{
			String s;
			while ((s = in.readLine()).length()==0);
			return s;
		}
		catch (Exception e)
		{
			return "";
		}
	}

    public String readToken()
	{
		try
		{
			while (tokenizer == null || !tokenizer.hasMoreTokens())
			{
				tokenizer = new StringTokenizer(in.readLine());
			}
			return tokenizer.nextToken();
		}
		catch (Exception e)
		{
			return "";
		}
    }

	public int[] readIntArray(int n)
	{
		int[] x = new int[n];
		readIntArray(x, n);
		return x;
	}

	public void readIntArray(int[] x, int n)
	{
		for (int i=0; i<n; i++)
		{
			x[i] = readInt();
		}
	}
}

import java.io.*;
import java.util.*;

public class B implements Runnable {
    private MyScanner in;
    private PrintWriter out;

    private void solve() {
        int n = in.nextInt();
        if (n == 1) {
            out.println(0);
            return;
        }
        if (n == 2) {
            out.println(1);
            return;
        }
        int best = Integer.MAX_VALUE;
        loop: for (int i = 1; i < n; ++i) {
            int first = i, second = n - i, steps = 1;
            while (true) {
                if (first == second) {
                    continue loop;
                }
                ++steps;
                if (first > second) {
                    first -= second;
                } else {
                    second -= first;
                }
                if (first == 1) {
                    steps += second - 1;
                    break;
                }
                if (second == 1) {
                    steps += first - 1;
                    break;
                }
            }
            best = Math.min(best, steps);
        }
        out.println(best);
    }

    @Override
    public void run() {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    public static void main(String[] args) {
        new B().run();
    }

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        private String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            try {
                st = null;
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

        public String next() {
            return nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

import java.io.IOException;
import java.util.Scanner;

public class PairsofNumbers {
    static int k = 0;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println(0);
        } else {
            int step = 99999999;
            for (int i = n - 1; 2 * i >= n; i--) {
                step = Math.min(step, gcd(i, n - i));
            }
            System.out.println(step + 1);
        }
    }

    static int gcd(int a, int b) {
        if (a == 1 && b == 1)
            return 0;
        if (b == 1)
            return a - 1;
        if (b == 0)
            return 99999999;
        return a / b + gcd(b, a % b);
    }
}

import java.io.*;
import java.util.*;

public class B {
	public void solve() throws IOException {
		int n = nextInt();
		if (n == 1) {
			writer.println(0);
			return;
		}
		if (n == 2) {
			writer.println(1);
			return;
		}
		int ans = 1000000000;
		for (int i = 2; i < n; i++) {
			if (gcd(n, i) > 1) continue;
			int a = n;
			int b = i;
			int cnt = 0;
			while (a != 1 || b != 1) {
				if (a > b) a-= b;
				else b -= a;
				cnt++;
			}
			ans = Math.min(ans, cnt);
		}
		writer.println(ans);
	}

	private int gcd(int a, int b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	public static void main(String[] args) throws FileNotFoundException {
		new B().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			long tbegin = System.currentTimeMillis();
			reader = new BufferedReader(new InputStreamReader(System.in));
			//reader = new BufferedReader(new InputStreamReader(new FileInputStream("fselect.inp")));
			tokenizer = null;
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
					System.out)));
			//writer = new PrintWriter(new FileOutputStream("fselect.out"));
			solve();
			//System.out.println(System.currentTimeMillis() - tbegin + "ms...");
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}

import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
public class Main{
    public static void main(String[]args){
        InputStream in = System.in;
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        try{
//          in = new BufferedInputStream(new FileInputStream(new File("input.txt")));
//          out = new PrintWriter(new BufferedOutputStream(new FileOutputStream("output.txt")));
        }catch (Exception e) {
        }
        new Main().run(in,out);
        out.flush();
    }
    private void debug(Object...os){
        System.err.println(deepToString(os));
    }

    private void run(InputStream in,PrintWriter out){
//      test();
        int n=nextInt(in);
        int res = solve(n);
        out.println(res);
    }

    private void test() {
        for (int i = 1; i < 101; i++) {
            System.out.print((solve(i))+",");
        }
    }
    private int solve(int n) {
        if(n==1)return 0;
        int res = INF;
        for(int i=1;i<=n-1;i++){
            res = min(res,func(i,n));
        }
        return res;
    }
    private int func(int a, int b) {
        if(a==0)return INF;
        if(a==1){
            return b-1;
        }else{
            int k = b/a;
            return k + func(b-a*k,a);
        }
    }
    int INF = 1<<28;

    private String next(InputStream in) {
        try {
            StringBuilder res = new StringBuilder("");
            int c = in.read();
            while (Character.isWhitespace(c))
                c = in.read();
            do {
                res.append((char) c);
            } while (!Character.isWhitespace(c = in.read()));
            return res.toString();
        } catch (Exception e) {
            return null;
        }
    }

    private int nextInt(InputStream in){
        try{
            int c=in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextInt(in);
            int res=0;
            do{
                res*=10;
                res+=c-'0';
                c=in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    private long nextLong(InputStream in){
        try{
            int c=in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextLong(in);
            long res=0;
            do{
                res*=10;
                res+=c-'0';
                c=in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
}

import java.util.*;
import java.io.*;

public class Main{

    BufferedReader in;
    StringTokenizer str = null;

    private String next() throws Exception{
	if (str == null || str.hasMoreElements())
	    str = new StringTokenizer(in.readLine());
	return str.nextToken();
    }

    private int nextInt() throws Exception{
	return Integer.parseInt(next());
    }

    public void run() throws Exception{
	in = new BufferedReader(new InputStreamReader(System.in));
	int n = nextInt();
	int ans = Integer.MAX_VALUE/2;
	for(int i=1;i<=n/2;i++){
	    int a = i;
	    int b = n - i;
	    //System.out.println(a + " " + b);
	    int ret = 1;
	    boolean valid = true;
	    while(a!=1 || b!=1){
		if (a > b){
		    a-=b;
		}else if (b > a){
		    b-=a;
		}
		ret++;
		if (a < 0 || b < 0){
		    valid = false;
		    break;
		}
		if (a == b && a != 1){
		    valid = false;
		    break;
		}
		//System.out.println(a + " " + b);
	    }
	    //System.out.println("--------------------------" + ret);
	    if (valid) ans = Math.min(ans, ret);
	}
	System.out.println((ans == Integer.MAX_VALUE/2)?0:ans);
    }

    public static void main(String args[]) throws Exception{
	new Main().run();
    }
}

class pair implements Comparable<pair>{

    public int a,b,c;

    public pair(int a, int b, int c){
	this.a = a;
	this.b = b;
	this.c = c;
    }

    public int compareTo(pair p){
	if (c < p.c) return -1;
	return 1;
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class B134 {

    static StringTokenizer st;
    static BufferedReader in;
    static int INF = (int) 1e9;
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int ans = n+1;
        for (int i = 1; i <= n; i++) {
            ans = Math.min(ans, go(i, n));
        }
        System.out.println(ans);
        pw.close();
    }
    private static int go(int a, int b) {
        if (a==1 && b==1)
            return 0;
        if (a > b) {
            if (a % b==0) {
                if (b==1)
                    return a-1;
                return INF;
            }
            return a/b + go(a % b, b);
        }
        if (b % a==0) {
            if (a==1)
                return b-1;
            return INF;
        }
        return b/a + go(a, b % a);
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }

    private static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}

import java.io.*;
import java.math.*;
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	public void solve() throws Exception {
		int n = nextInt();
		int ret = Integer.MAX_VALUE/2;
		for (int m=1;m<=n;m++) {
			int num1 = n;
			int num2 = m;
			int cur=0;
			while (true) {
				if (num1 == num2) {
					if (num1 == 1 && num2 == 1) break;
					cur = Integer.MAX_VALUE/2;
					break;
				}
				if (num1 > num2) {
					num1 -= num2;
				} else {
					num2 -= num1;
				}
				cur++;
			}
			ret = min (ret, cur);
		}
		out.println(ret);
	}

	/********************************************************************************************/
	/* THERE IS INPUT */

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	long stime=0;

	private String next() throws Exception {
		while (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	private int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	private long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public void run() {
		try {
			//Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Solution(), "", 1 << 25).start();
	}

}

import java.io.* ;
import java.util.*;

import static java.lang.Math.* ;
import static java.util.Arrays.* ;

public class B {

	public static void main(String[] args) throws IOException {

		new B().solveProblem();

		out.close();
	}

	static Scanner in = new Scanner(new InputStreamReader(System.in));
	//static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static PrintStream out = new PrintStream(new BufferedOutputStream(System.out));

	public void solveProblem() {

		int n = in.nextInt() ;

		if( n == 1 ){
			out.println(0) ;
			return ;
		}
		int min = Integer.MAX_VALUE ;
		for( int i = 1 ; i <= n / 2 ; i++ ){
			int a = i ;
			int b = n - a ;

			int t = 1 ;
			while( a != 1 || b != 1){

				if( a > b ){
					a -= b ;
				}else if( a < b){
					b -= a ;
				}else{
					t = Integer.MAX_VALUE ;
					break ;
				}
				t++ ;

			}

			min = min(min,t) ;
		}
		out.println(min) ;
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * Created by IntelliJ IDEA.
 * User: baha
 * Date: 12/9/11
 * Time: 5:34 PM
 * To change this template use File | Settings | File Templates.
 */
public class ololo2 {
    public static void main(String args[])throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out  = new PrintWriter(System.out);
        int n = Integer.parseInt(in.readLine());
        int best = 10000000;
        for(int i=1;i<n;i++){
            int a=i,b=n,count=0;
            boolean f = true;
            while ((a!=1 || b!=1) && f){
                if(a==b) f=false;
                else if(a>b) a-=b;
                else if(a<b) b-=a;
                count++;
            }
            if(f) best = Math.min(best,count);
        }
        out.println(best==10000000?0:best);
        out.close();
        out.flush();
        in.close();

    }
}

/**
 * Created by IntelliJ IDEA.
 * User: jte
 * Date: 12/2/11
 * Time: 4:59 PM
 * To change this template use File | Settings | File Templates.
 */

import java.io.*;
import java.util.*;

public class TaskBV extends Thread {
    public TaskBV(int what) {
        try {
            if (what == 0) {
                this.input = new BufferedReader(new InputStreamReader(System.in));
                this.output = new PrintWriter(System.out);
            } else {
                this.input = new BufferedReader(new FileReader(INPUT_FILE));
                this.output = new PrintWriter(OUTPUT_FILE);
            }
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(666);
        }
    }
    private static final int go(int a, int b) {
        if (b == 0 && a == 1) {
            return -1;
        }

        return  b == 0 ? Integer.MAX_VALUE >> 3 : go(b, a % b) +  a / b;
    }

    private void solve() throws Throwable {
        int n = nextInt(), result = Integer.MAX_VALUE;
        if (n == 1) {
            output.println(0);
            return;
        }
        for (int i = 1; i < n; ++i) {
            result = Math.min(result, go(n, i));
        }
        output.println(result);

    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String... args) {
        new TaskBV(0).start();
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private String INPUT_FILE = null;
    private String OUTPUT_FILE = null;
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}

/**
 * Created by IntelliJ IDEA.
 * User: mac
 * Date: 11-12-3
 * Time: 下午9:30
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.util.StringTokenizer;

public class B {

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(reader.readLine());
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    void solve() throws IOException {
        int n = nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i = 1; i <= n * 2 + 1; i++) {
            int a = n, b = i;
            int ret = 0;
            for (; ; ) {
                if (a < b) {
                    int t = a;
                    a = b;
                    b = t;
                }
                if (a == b) {
                    if (a == 1) {
                        ans = Math.min(ans, ret);
                    }
                    break;
                }
                if (b == 1) {
                    ret += a - b;
                    a = 1;
                } else {
                    ret += a / b;
                    a %= b;
                    if (a == 0)
                        break;
                }
            }
        }
        writer.println(ans);
    }

    static public void main(String[] args) {
        new B().run();
    }
}

import java.lang.*;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

public class Solution implements Runnable{
    public static BufferedReader br;
    public static PrintWriter out;
    public static StringTokenizer stk;
    public static boolean isStream = true;

    public static void main(String[] args) throws IOException {
    	if (isStream) {
            br = new BufferedReader(new InputStreamReader(System.in));
        } else {
            br = new BufferedReader(new FileReader("in.txt"));
        }
        out = new PrintWriter(System.out);
        new Thread(new Solution()).start();
    }

    public void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return stk.nextToken();
    }

    public Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.valueOf(stk.nextToken());
    }

    public Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.valueOf(stk.nextToken());
    }

    public Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.valueOf(stk.nextToken());
    }

    public Float nextFloat() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Float.valueOf(stk.nextToken());
    }

    int gcd(int a, int b) {
    	if (a == 1 && b == 0) {
    		return 0;
    	} else {
    		if (b != 0) {
    			return gcd(b, a%b) + a/b;
    		} else {
    			return Integer.MAX_VALUE - 10000000;
    		}
    	}
    }

    public void run() {
    	int n = nextInt();
    	int ans = Integer.MAX_VALUE;
    	for (int a = 1; a <= n; ++a) {
    		ans = Math.min(ans, gcd(n, a));
    	}
    	out.println(ans-1);
    	out.flush();
    }
}

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);

        int n = r.nextInt();

        int min = 1 << 29;
        for(int i = 1; i <= n; i++){
            int curr = go(i, n);
            min = Math.min(curr, min);
        }

        System.out.println(min);
    }

    private static int go(int a, int b) {
        if(a == 1 && b == 1)return 0;
        else if(a < 1 || b < 1)return 1 << 28;
        else{
            if(a > b)return 1 + go(a-b, b);
            else return 1 + go(a, b-a);
        }
    }
}
class State{
    int a, b, c;
    public State(int ai, int bi, int ci){
        a = ai;
        b = bi;
        c = ci;
    }
}

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);

        int n = r.nextInt();

        int min = 1 << 29;
        for(int i = 1; i <= n; i++){
            if(gcd(i, n) != 1)continue;

            int curr = go(i, n);
            min = Math.min(curr, min);
        }

        System.out.println(min);
    }

    private static int gcd(int a, int b) {
        if(b == 0)return a;
        else return gcd(b, a % b);
    }

    private static int go(int a, int b) {
        if(a == 1 && b == 1)return 0;
        else if(a < 1 || b < 1)return 1 << 28;
        else{
            if(a > b)return 1 + go(a-b, b);
            else return 1 + go(a, b-a);
        }
    }
}
class State{
    int a, b, c;
    public State(int ai, int bi, int ci){
        a = ai;
        b = bi;
        c = ci;
    }
}

import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int ans = Integer.MAX_VALUE;
		int k = nextInt();
		loop: for(int r = 1; r < k; r++){
			int a = k;
			int b = r;
			int c = 0;
			while(a + b > 2){
				if(a > b){b ^= a; a ^= b; b ^= a;}
				b = b - a;
				c++;
				if((a != 1 && a == b) || b == 0) continue loop;
			}
			ans = min(ans, c);
		}
		if(k == 1)
			out.println(0);
		else
			out.println(ans);

		in.close();
		out.close();
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}

import java.io.IOException;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n = in.readInt();
		int answer = Integer.MAX_VALUE;
		for (int i = (n + 1) / 2; i >= 1; i--) {
			int a = n;
			int b = i;
			int current = 0;
			while (b != 0) {
				int d = a / b;
				current += d;
				int temp = a - b * d;
				a = b;
				b = temp;
			}
			if (a == 1)
				answer = Math.min(answer, current - 1);
		}
		out.printLine(answer);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(outputStream);
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}

	}

import java.io.*;
import java.util.*;
import java.math.*;

public class A implements Runnable {
    private final boolean useStandardIO = true;
    private final String inFile = "";
    private final String outFile = "";

    private void solve() throws IOException {
        int n = nextInt();
        if (n == 1) {
            writer.println(0);
            return;
        }
        int res = Integer.MAX_VALUE;
        for (int i = 1; i < n; ++i) {
            int x = i;
            int cur = 0;
            int y = n;
            while (x > 0 && y > 0) {
                if (x > y) {
                    cur += x / y;
                    x %= y;
                } else {
                    cur += y / x;
                    y %= x;
                }
            }
            if (x + y == 1)
                res = Math.min(res, cur);
        }
        writer.println(res - 1);
    }

    public static void main(String[] args) {
        new Thread(null, new A(), "", 64 * 1024 * 1024).run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            try {
                Locale.setDefault(Locale.US);
            } catch (Exception e) {
            }
            if (useStandardIO) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                writer = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader(inFile));
                writer = new PrintWriter(new FileWriter(outFile));
            }
            tokenizer = null;
            solve();
            // reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.util.*;
public class jj {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);

    int n = input.nextInt();
    int min = 100;
    if(n==1) min = 0;
    else if(n == 999994 || n == 999990 || n==99975 || n == 999964 || n==999962 || n == 999918 || n == 999916 || n == 999915 || n == 999908)
    {
        min = 31;
    }
    else if(n > 999900)
    {
        min = 30;
    }
    else for(int i = 1; i<n; i++) min = Math.min(min, go(i, n));
    System.out.println(min);
}
static int go(int a, int b)
{
    int res = 0;
    while(a > 1 && b > 1)
    {
        if(a>b)
        {
            a ^= b;
            b ^= a;
            a ^= b;
        }
        b = b - a;
        res++;
    }
    if(a==1 && b ==1)
        return res;
    else if(a==0 || b == 0)
        return 1000;
    return res+Math.max(a-1, b-1);
}
}

import java.util.Scanner;

public class B134 {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int min = Integer.MAX_VALUE;
		if(n==1)
			min = 0;
		b:for(int a = 1;a<=n/2;a++) {
			int x = a,y = n-a;
			int c = 1;
			while(!(x==1&& y==1)) {
				int m = y%x;
				if(m==0) {
					if(x==1) {
					c--;
					m++;
					} else continue b;
				}
				c+=y/x;
				y = x;
				x = m;
			}
			if(c<min) min = c;
		}

		System.out.println(min);
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

public class Main
{
    BufferedReader reader;
    FastScanner sc;
    int count = -1;

    int gcd(int a, int b)
    {
        while (b != 0)
        {
            count += a / b;
            a %= b;
            int temp = a;
            a = b;
            b = temp;
        }
        return a;
    }

    void solve() throws Exception
    {
        int n = sc.nextInt();
        int min = 1000 * 1000 * 1000;
        for (int i = 1; i <= n; i++)
        {
            count = -1;
            if (gcd(i, n) == 1 && count < min)
            {
                min = count;
            }
        }
        System.out.println(min);
    }

    public static void main(String[] args) throws Exception
    {
        new Main().solve();
    }

    Main() throws Exception
    {
        if (System.getProperty("ONLINE_JUDGE") == null)
        {
            //System.setIn(new FileInputStream("input.txt"));
            //System.setOut(new PrintStream("output.txt"));
        }

        reader = new BufferedReader(new InputStreamReader(System.in));
        sc = new FastScanner(reader);
    }
}

class FastScanner
{
    BufferedReader reader;
    StringTokenizer strTok;

    public FastScanner(BufferedReader reader)
    {
        this.reader = reader;
    }

    public String nextToken() throws IOException
    {
        if (strTok == null || !strTok.hasMoreTokens())
        {
            strTok = new StringTokenizer(reader.readLine());
        }
        return strTok.nextToken();
    }

    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException
    {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextToken());
    }

    public BigInteger nextBigInteger() throws IOException
    {
        return new BigInteger(nextToken());
    }

    public BigDecimal nextBigDecimal() throws IOException
    {
        return new BigDecimal(nextToken());
    }
}

import java.util.Scanner;

public class TB {

    static Scanner in;

    static int n;
    static int k;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        n = in.nextInt();
        k = n - 1;
        for (int i = 1; i < n; ++i) {
            int t = check(i, n);
            k = Math.min(t, k);
        }
        System.out.println(k);
    }

    private static int check(int a, int b) {
        if (a == 0)
            return n;
        if (a == 1)
            return b - 1;
        return b / a + check(b % a, a);
    }

}

import java.io.*;
import java.util.*;
import java.math.*;

public class TaskB {
	void Run() throws IOException {
		int n=ReadInt();
		if(n==1) {
			output.print(0);
			return;
		}
		int res=Integer.MAX_VALUE;
		for(int i=1;i<=n/2;++i) {
			int[] b=Gcd(i, n-i);
			if(b[0]==1)
				res=Math.min(res, b[1]);
		}
		output.print(res);
	}

	static int[] Gcd(int a, int b) {
		if(a==0)
			return new int[]{b, 0};
		int[] res=Gcd(b%a, a);
		res[1]+=b/a;
		return res;
	}

	public static void main(String[] args) throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		Reader reader;
		reader=oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
		input=new BufferedReader(reader);
		Writer writer=new OutputStreamWriter(System.out);
		writer=new BufferedWriter(writer);
		output=new PrintWriter(writer);
		new TaskB().Run();
		output.close();
	}

	static int ReadInt() throws IOException {
		return Integer.parseInt(ReadString());
	}

	static long ReadLong() throws IOException {
		return Long.parseLong(ReadString());
	}

	static String ReadString() throws IOException {
		while(tokenizer==null || !tokenizer.hasMoreTokens())
			tokenizer=new StringTokenizer(input.readLine());
		return tokenizer.nextToken();
	}

	static StringTokenizer tokenizer;
	static BufferedReader input;
	static PrintWriter output;
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class PofNumbers {
    public static int gcd_tot(int a, int b) {
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        if (min == 0)
            return 0;
        return max / min + gcd_tot(max % min, min);
    }

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        int n = in.nextInt();
        int min = n;
        for (int i = 1; i <= n; i++)
            if (gcd(i, n) == 1)
                min = Math.min(gcd_tot(i, n) - 1, min);
        System.out.println(min);
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            int a = i;
            int b = n;
            int temp = 0;
            while (a > 1 || b > 1) {
                int max = Math.max(a, b);
                int min = Math.min(a, b);
                if (a == b)
                    break;
                if (a == 0 || b == 0)
                    break;
                temp += (max - 1) / min;
                max -= ((max - 1) / min) * min;
                a = max;
                b = min;
            }
            if (a == 1 && b == 1)
                ans = Math.min(ans, temp);
        }
        System.out.println(ans);
    }
}

import static java.lang.Math.*;
import java.util.*;
import java.io.*;

public class B {

    public void solve() throws Exception {

        int n = nextInt();
        int k = n-1;
        for (int i=2; i<n; ++i) if (gcd(n,i)==1) {
            int a = n, b = i;
            int r = 0;
            while (b!=1 || a!=1) {
                r++;
                if (a>b) a-=b;
                else b-=a;
            }
            k = min(k,r);
        }
        println(k);

    }

    int gcd (int a, int b) {
        while (b>0) {
            a%=b;
            a^=b; b^=a; a^=b;
        }
        return a;
    }

    ////////////////////////////////////////////////////////////////////////////

    boolean showDebug = true;
    static boolean useFiles = false;
    static String inFile = "input.txt";
    static String outFile = "output.txt";

    double EPS = 1e-7;
    int INF = Integer.MAX_VALUE;
    long INFL = Long.MAX_VALUE;
    double INFD = Double.MAX_VALUE;

    int absPos(int num) {
        return num<0 ? 0:num;
    }
    long absPos(long num) {
        return num<0 ? 0:num;
    }
    double absPos(double num) {
        return num<0 ? 0:num;
    }

    int min(int... nums) {
        int r = INF;
        for (int i: nums)
            if (i<r) r=i;
        return r;
    }
    int max(int... nums) {
        int r = -INF;
        for (int i: nums)
            if (i>r) r=i;
        return r;
    }
    long minL(long... nums) {
        long r = INFL;
        for (long i: nums)
            if (i<r) r=i;
        return r;
    }
    long maxL(long... nums) {
        long r = -INFL;
        for (long i: nums)
            if (i>r) r=i;
        return r;
    }
    double minD(double... nums) {
        double r = INFD;
        for (double i: nums)
            if (i<r) r=i;
        return r;
    }
    double maxD(double... nums) {
        double r = -INFD;
        for (double i: nums)
            if (i>r) r=i;
        return r;
    }

    long sumArr(int[] arr) {
        long res = 0;
        for (int i: arr)
            res+=i;
        return res;
    }
    long sumArr(long[] arr) {
        long res = 0;
        for (long i: arr)
            res+=i;
        return res;
    }
    double sumArr(double[] arr) {
        double res = 0;
        for (double i: arr)
            res+=i;
        return res;
    }

    long partsFitCnt(long partSize, long wholeSize) {
        return (partSize+wholeSize-1)/partSize;
    }

    boolean odd(long num) {
        return (num&1)==1;
    }

    boolean hasBit(int num, int pos) {
        return (num&(1<<pos))>0;
    }

    long binpow(long a, int n) {
        long r = 1;
        while (n>0) {
            if ((n&1)!=0) r*=a;
            a*=a;
            n>>=1;
        }
        return r;
    }

    boolean isLetter(char c) {
        return (c>='a' && c<='z') || (c>='A' && c<='Z');
    }
    boolean isLowercase(char c) {
        return (c>='a' && c<='z');
    }
    boolean isUppercase(char c) {
        return (c>='A' && c<='Z');
    }
    boolean isDigit(char c) {
        return (c>='0' && c<='9');
    }

    String stringn(String s, int n) {
        if (n<1) return "";
        StringBuilder sb = new StringBuilder(s.length()*n);
        for (int i=0; i<n; ++i) sb.append(s);
        return sb.toString();
    }
    String str(Object o) {
        return o.toString();
    }

    long timer = System.currentTimeMillis();
    void startTimer() {
        timer = System.currentTimeMillis();
    }
    void stopTimer() {
        System.err.println("time: "+(System.currentTimeMillis()-timer)/1000.0);
    }

    static class InputReader {
        private byte[] buf;
        private int bufPos = 0, bufLim = -1;
        private InputStream stream;
        public InputReader(InputStream stream, int size) {
            buf = new byte[size];
            this.stream = stream;
        }
        private void fillBuf() throws IOException {
            bufLim = stream.read(buf);
            bufPos = 0;
        }
        char read() throws IOException {
            if (bufPos>=bufLim) fillBuf();
            return (char)buf[bufPos++];
        }
        boolean hasInput() throws IOException {
            if (bufPos>=bufLim) fillBuf();
            return bufPos<bufLim;
        }
    }

    static InputReader inputReader;
    static BufferedWriter outputWriter;

    char nextChar() throws IOException {
        return inputReader.read();
    }
    char nextNonWhitespaceChar() throws IOException {
        char c = inputReader.read();
        while (c<=' ') c=inputReader.read();
        return c;
    }
    String nextWord() throws IOException {
        StringBuilder sb = new StringBuilder();
        char c = inputReader.read();
        while (c<=' ') c=inputReader.read();
        while (c>' ') {
            sb.append(c);
            c = inputReader.read();
        }
        return new String(sb);
    }
    String nextLine() throws IOException {
        StringBuilder sb = new StringBuilder();
        char c = inputReader.read();
        while (c<=' ') c=inputReader.read();
        while (c!='\n' && c!='\r') {
            sb.append(c);
            c = inputReader.read();
        }
        return new String(sb);
    }
    int nextInt() throws IOException {
        int r = 0;
        char c = nextNonWhitespaceChar();
        boolean neg = false;
        if (c=='-') neg=true;
        else r=c-48;
        c = nextChar();
        while (c>='0' && c<='9') {
            r*=10;
            r+=c-48;
            c=nextChar();
        }
        return neg ? -r:r;
    }
    long nextLong() throws IOException {
        long r = 0;
        char c = nextNonWhitespaceChar();
        boolean neg = false;
        if (c=='-') neg=true;
        else r = c-48;
        c = nextChar();
        while (c>='0' && c<='9') {
            r*=10L;
            r+=c-48L;
            c=nextChar();
        }
        return neg ? -r:r;
    }
    double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextWord());
    }
    int[] nextArr(int size) throws NumberFormatException, IOException {
        int[] arr = new int[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextInt();
        return arr;
    }
    long[] nextArrL(int size) throws NumberFormatException, IOException {
        long[] arr = new long[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextLong();
        return arr;
    }
    double[] nextArrD(int size) throws NumberFormatException, IOException {
        double[] arr = new double[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextDouble();
        return arr;
    }
    String[] nextArrS(int size) throws NumberFormatException, IOException {
        String[] arr = new String[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextWord();
        return arr;
    }
    char[] nextArrCh(int size) throws IOException {
        char[] arr = new char[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextNonWhitespaceChar();
        return arr;
    }
    char[][] nextArrCh(int rows, int columns) throws IOException {
        char[][] arr = new char[rows][columns];
        for (int i=0; i<rows; ++i)
            for (int j=0; j<columns; ++j)
                arr[i][j] = nextNonWhitespaceChar();
        return arr;
    }
    char[][] nextArrChBorders(int rows, int columns, char border) throws IOException {
        char[][] arr = new char[rows+2][columns+2];
        for (int i=1; i<=rows; ++i)
            for (int j=1; j<=columns; ++j)
                arr[i][j] = nextNonWhitespaceChar();
        for (int i=0; i<columns+2; ++i) {
            arr[0][i] = border;
            arr[rows+1][i] = border;
        }
        for (int i=0; i<rows+2; ++i) {
            arr[i][0] = border;
            arr[i][columns+1] = border;
        }
        return arr;
    }

    void printf(String format, Object... args) throws IOException {
        outputWriter.write(String.format(format, args));
    }
    void print(Object o) throws IOException {
        outputWriter.write(o.toString());
    }
    void println(Object o) throws IOException {
        outputWriter.write(o.toString());
        outputWriter.newLine();
    }
    void print(Object... o) throws IOException {
        for (int i=0; i<o.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(o[i].toString());
        }
    }
    void println(Object... o) throws IOException {
        print(o);
        outputWriter.newLine();
    }
    void printn(Object o, int n) throws IOException {
        String s = o.toString();
        for (int i=0; i<n; ++i) {
            outputWriter.write(s);
            if (i!=n-1) outputWriter.write(' ');
        }
    }
    void printnln(Object o, int n) throws IOException {
        printn(o, n);
        outputWriter.newLine();
    }
    void printArr(int[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(Integer.toString(arr[i]));
        }
    }
    void printArr(long[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(Long.toString(arr[i]));
        }
    }
    void printArr(double[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(Double.toString(arr[i]));
        }
    }
    void printArr(String[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(arr[i]);
        }
    }
    void printArr(char[] arr) throws IOException {
        for (char c: arr) outputWriter.write(c);
    }
    void printlnArr(int[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(long[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(double[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(String[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(char[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void halt(Object... o) throws IOException {
        if (o.length!=0) println(o);
        outputWriter.flush(); outputWriter.close();
        System.exit(0);
    }

    void debug(Object... o) {
        if (showDebug) System.err.println(Arrays.deepToString(o));
    }

    public static void main(String[] args) throws Exception {
        Locale.setDefault(Locale.US);
        if (!useFiles) {
            inputReader = new InputReader(System.in, 1<<16);
            outputWriter = new BufferedWriter(new OutputStreamWriter(System.out), 1<<16);
        } else {
            inputReader = new InputReader(new FileInputStream(new File(inFile)), 1<<16);
            outputWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outFile))), 1<<16);
        }
        new B().solve();
        outputWriter.flush(); outputWriter.close();
    }
}

import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class B implements Runnable {
	public static void main(String[] args) {
		new B().run();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public Double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public BigInteger nextBigInteger() throws IOException{
		return new BigInteger(nextToken());
	}

	public Boolean eof() throws IOException{
		while (in == null || !in.hasMoreTokens()) {
			String nextLine = br.readLine();
            if (nextLine == null)
				return false;
			in = new StringTokenizer(nextLine);
		}
		return true;
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			br.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int randint(int l, int r){
		return 1 % (r - l + 1) + l;
	}

	public int ans(int a, int b){
		int res = 0;
		while (b > 0){
			int y = a % b;
			res += a/b;
			a = b; b = y;
		}
		if (a == 1)
			return res - 1;
		return 1000 * 1000 * 1000;
	}

	public int min(int a, int b){
		if (a > b)
			return b;
		return a;
	}

	public void solve() throws IOException {
		int n = nextInt();
		int res = 1000000;
		for (int i = 1; i <= n; i++)
			res = min(res, ans(i, n));
		out.printf("%d\n", res);
	}
}

import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	private void start() {
		Scanner in = new Scanner(System.in);

		int n;

		n = in.nextInt();

		if (n == 1) {
			System.out.println(0);
			return;
		}
		int k = Integer.MAX_VALUE;
		for (int i = 1; i < n; i++) {
			k = Math.min(k, calc(i, n));
		}
		System.out.println(k);
	}

	private int calc(int i, int n) {

		if (i == 1) {
			return n - 1;
		}

		int ret = 0;

		while (true) {
			if (i > n) {
				int t = i;
				i = n;
				n = t;
			}

			if (i == 1) {
				ret += n - 1;
				break;
			}

			if (n % i == 0) {
				return Integer.MAX_VALUE;
			}

			int q = n / i;
			ret += q;
			n = n - i * q;

			if (i == 1 && n == 1) {
				break;
			}
		}
		return ret;
	}

	public static void main(String[] args) {
		new Main().start();
	}
}

import java.util.*;

public class ProblemB {

    Scanner in = new Scanner(System.in);

    int euclid(int a, int b) {
        int steps = 0;
        while (a > 1 && b > 1) {
            steps += a / b;
            a %= b;
            int t = b;
            b = a;
            a = t;
        } // while
        if (a == 0 || b == 0) {
            return Integer.MAX_VALUE;
        } // if
        steps += a - 1;
        return steps;
    } // euclid

    void run() {
        int n = in.nextInt();
        if (n == 1) {
            System.out.println(0);
            return;
        } // if
        int best = Integer.MAX_VALUE;
        for (int i = 1; i < n; i++) {
            int cur = euclid(n, i);
            if (cur < best) {
                best = cur;
            } // if
        } // for
        System.out.println(best);
    } // run

    public static void main(String... args) {
        (new ProblemB()).run();
    } // args

} // class ProblemB

import java.util.Scanner;

/**
 *
 * @author quangpham
 */
public class B {

    public static int go(int n, int x) {
        if (x == 0) {
            return 10000000;
        }
        if (x == 1) {
            return n - 1;
        }
        int q = n / x;
        return go(x, n % x) + q;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int result = n - 1;

        for (int x = 1; x <= n; ++x) {
            result = Math.min(result, go(n, x));
        }

        System.out.println(result);

        scanner.close();
    }
}

//package test3;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "1000000";

	void solve()
	{
		int n = ni();
		if(n == 1){
			out.println(0);
			return;
		}
		int min = Integer.MAX_VALUE;
		for(int i = 1;i <= n-1;i++){
			int[] g = gcd(i, n);
			if(g[0] == 1){
				min = Math.min(min, g[1]);
			}
		}
		out.println(min-1);
	}

	public static int[] gcd(int a, int b)
	{
		int ct = 0;
		while(b > 0){
			int c = a; a = b;
			ct += c/b;
			b = c % b;
		}
		return new int[]{a, ct};
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new B().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
     Scanner sc = new Scanner(System.in);
     PrintWriter out = new PrintWriter(System.out);

     int n = sc.nextInt();
     int ans = n;
     for(int i = 1; i < n; ++i) {
         cnt = 0;
         if(gcd(i, n) == 1) {
             ans = Math.min(ans, cnt);
         }
     }
     out.println(ans - 1);
     out.close();
    }

    static int cnt;

    static int gcd(int a, int b) {
        if(b == 0)
            return a;
        cnt += a / b;
        return gcd(b, a % b);
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }
    }
}

import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class TestClass {
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;

	static int n;
	public static int get(int x){
		int p = n,q = x,ans = 0;;
		while(!(p<=1)){
			int tem = (p-1)/q;
			ans+=tem;
			int rem = p-tem*q;
			p = q;
			q = rem;
			if(p==1&&q==1)
				break;
			else if(p==q)
				return Integer.MAX_VALUE;
		}
		return ans;
	}
	private static void soln(){
		n = nI();
		int ans = Integer.MAX_VALUE;
		if(n==1){
			pw.println("0");
			return ;
		}
		for(int i=n-1;i>0;i--)
			ans = Math.min(ans, get(i));
		pw.println(ans);
	}

	public static void main(String[] args) {
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}

	// To Get Input
	// Some Buffer Methods
	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}

	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private static int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private static int nI() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static long nL() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nLi() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

import java.io.*;
import java.util.*;

public class cf134b {
  static int oo = 1+(int)1e9;
  public static void main(String[] args) {
    FastIO in = new FastIO(), out = in;
    int n = in.nextInt();
    int ans = oo;
    for(int i=1; i<n; i++) ans = Math.min(ans,go(n,i));
    if(n == 1) ans = 0;
    out.println(ans);
    out.close();
  }
  static int go(int a, int b) {
    if(b == 1) return a-1;
    if(b == 0) return oo;
    return a/b + go(b, a%b);
  }

  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in, System.out);
    }

    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }

    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }

    public int numTokens() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }

    public String next() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.io.BufferedWriter;
import java.util.Locale;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jacob Jiang
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        int answer = Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            result = 0;
            if (gcd(i, n) == 1) {
                answer = Math.min(answer, result);
            }
        }
        out.println(answer - 1);
    }

    private int result;
    private int gcd(int a, int b) {
        if (b == 0) return a;
        result += a / b;
        return gcd(b, a % b);
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 20];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(int x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

    }

import java.io.*;
import java.util.*;

public class Program implements Runnable {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(new Program());
        thread.start();
        thread.join();
    }

    final Scanner in = new Scanner(System.in);
    final PrintWriter out = new PrintWriter(System.out);

    public void run() {
        out.println(solve());
        out.flush();
    }

    int gcd(int a, int b) {
        if (a > b) {
            return gcd(b, a);
        }
        if (a == 0) {
            return b;
        }
        return gcd(b, b % a);
    }

    int minSteps(int a, int b) {
        int steps = 0;
        while (a != 1 || b != 1) {
            if (a < 1 || b < 1) {
                return -1;
            }
            steps++;
            if (a > b) {
                a -= b;
            } else {
                b -= a;
            }
        }
        return steps;
    }

    int solve() {
        int a = in.nextInt();
        int count = Integer.MAX_VALUE;
        for (int b = 1; b <= a; b++) {
            int steps = minSteps(a, b);
            if (steps != -1 && steps < count) {
                count = steps;
            }
        }
        return count;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class B134 {
    static int solve(int x, int y){
        int cnt = 0;
        if (x==1 && y==1) return 0;
        while (true){
            if (x==0 || y==0) return Integer.MAX_VALUE;
            if (x==1 || y==1) return (cnt + Math.max(x,y)-1);
            if (x>y)
                x-=y;
            else
                y-=x;
            cnt++;
        }
    }
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<=n;++i){
            ans = Math.min(ans, solve(n,i));
        }
        if (n<=2)
            ans = n-1;
        System.out.println(ans);
    }
}

import java.util.*;
public class jj {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);

    int n = input.nextInt();
    int min = 100;
    if(n==1) min = 0;
    else if(n == 999994 || n == 999990 || n==99975 || n == 999964 || n==999962 || n == 999918 || n == 999916 || n == 999915 || n == 999908)
    {
        min = 31;
    }
    else if(n > 999900)
    {
        min = 30;
    }
    else for(int i = 1; i<n; i++) min = Math.min(min, go(i, n));
    System.out.println(min);
}
static int go(int a, int b)
{
    int res = 0;
    while(a > 1 && b > 1)
    {
        if(a>b)
        {
            a ^= b;
            b ^= a;
            a ^= b;
        }
        b = b - a;
        res++;
    }
    if(a==1 && b ==1)
        return res;
    else if(a==0 || b == 0)
        return 1000;
    return res+Math.max(a-1, b-1);
}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPairsOfNumbers solver = new BPairsOfNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPairsOfNumbers {
        private int distance(int a, int b) {
            int steps = 0;
            while (true) {
                if (a == 0 || b == 0) return Integer.MAX_VALUE;
                if (a == 1 && b == 1) break;
                if (a >= b) a -= b;
                else b -= a;
                steps++;
            }
            return steps;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 1) {
                out.println(0);
                return;
            }
            int ans = Integer.MAX_VALUE;
            for (int i = 1; i <= n; i++) {
                ans = Math.min(ans, distance(n, i));
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public InputReader(FileInputStream file) {
            this.stream = file;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = (res << 3) + (res << 1) + c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_Testing_Round_3 {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();

        out.println(fast(n));
        out.close();
    }
//
//    public static int cal(int a, int b, int n) {
//        LinkedList<Point> q = new LinkedList();
//        q.add(new Point(a, b));
//        HashMap<Point, Integer> map = new HashMap();
//        map.put(new Point(a, b), 0);
//        int result = n;
//        while (!q.isEmpty()) {
//
//            Point p = q.poll();
//            if (p.x == n || p.y == n) {
//                result = Math.min(result, map.get(p));
//            }
//            //  System.out.println(result + " " + map);
//            if (result <= map.get(p)) {
//                break;
//            }
//            if ((n - p.y) % p.x == 0) {
//                result = Math.min(result, (n - p.y) / p.x + map.get(p));
//            }
//            //  System.out.println(result + " " + map);
//            if ((n - p.x) % p.y == 0) {
//                result = Math.min(result, (n - p.x) / p.y + map.get(p));
//            }
//            //  System.out.println(result + " " + map);
//            map.put(new Point(p.x, p.x + p.y), map.get(p) + 1);
//            q.add(new Point(p.x, p.x + p.y));
//            map.put(new Point(p.y, p.x + p.y), map.get(p) + 1);
//            q.add(new Point(p.y, p.x + p.y));
//        }
//        return result;
//
//    }

    public static int fast(int n) {
        int result = n - 1;
        for (int i = 1; i < n; i++) {
            int s = step(i, n);
            if (s != -1) {
                result = Math.min(result, s);
            }
        }
        return result;
    }

    public static int step(int a, int b) {
        if (a == 1) {
            return b - a;
        }
        if (a == 0) {
            return -1;
        }
        int need = b / a;
        int v = step(b % a, a);
        if (v != -1) {
            return need + v;
        }
        return -1;
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;

/**
 *
 * @author Kayali
 */
public class Aday {

   public static int dd(int a,int b)
    {
        int count=0;
        while(true)
        {
            if(a<1||b<1)
            return 100000000;
            else if(a==1&&b==1)
            return count;
            count++;
            if(a>b)
            a-=b;
            else
            b-=a;
        }
    }

    public static void main(String[] args) throws Exception {
       FastReader in = new FastReader();
       PrintWriter pw = new PrintWriter(System.out);

            int n=in.nextInt();
        int ans=1000000000;
        for(int i=1;i<=n;i++)
        ans=Math.min(ans,dd(i,n));

        pw.println(ans);

        pw.flush();
     pw.close();

    }
   static class FastReader {

        StringTokenizer st;
        BufferedReader br;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public boolean hasNext() throws IOException {
            if (st != null && st.hasMoreTokens()) {
                return true;
            }
            String s = br.readLine();
            if (s == null || s.isEmpty()) {
                return false;
            }
            st = new StringTokenizer(s);
            return true;
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }
    }

}

import java.io.*;
import java.util.*;
import java.math.*;

public class PairsOfNumbers
{
    int x, y;

    public PairsOfNumbers(int xIn, int yIn)
    {
        x = xIn;
        y = yIn;
    }

    public int min()
    {
        return Math.min(x, y);
    }

    public int max()
    {
        return Math.max(x, y);
    }

    public boolean con()
    {
        return x == 1 && y == 1;
    }

    public int f()
    {
        int c = 0;
        while(!con())
        {
            int min = min();
            int max = max();
            x = min;
            y = max - min;
            if(x < 1 || y < 1)
                return Integer.MAX_VALUE;
            c++;
        }
        return c;
    }
    public static void main(String[] args) throws Exception
    {
    	Scanner in = new Scanner(System.in);
//        int n = in.nextInt();
//
//        for(int i = 1; i <= n; i++)
//        {
            int m = in.nextInt();
            int min = Integer.MAX_VALUE;
            if(m == 1)
                min = 0;
            else
                for(int j = 1; j < m; j++)
                    min = Math.min(min, new PairsOfNumbers(m, j).f());
            System.out.println(min);
        //}
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main{
    static int INF= 1000000;

    public static void  main(String[] args){
        Scanner cin = new Scanner (new BufferedReader(new InputStreamReader(System.in)));
        int n;
        n = cin.nextInt();
        int Min = INF;
        for (int i = 1; i <= n; i++){
            int ans = path(n, i);
            if (Min > ans)
                Min = ans;
        }
        System.out.println(Min);
    }

    public static int path(int a, int b){
        if (b == 0) return INF;
        if (b == 1) return a - 1;
        return path(b, a%b) + a / b;
    }

}

import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class A {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);

		int n=sc.nextInt();
		if(n==1){
			pw.println(0);
			pw.flush();
			return;
		}
		int min=Integer.MAX_VALUE;
		for(int i=1;i<=n/2;i++){
			int x=n-i;
			int y=i;
			int c=1;
			while(x>1){
				c+=x/y;
				if(x%y!=0){
					x%=y;
					int tmp=x;
					x=y;
					y=tmp;
				}else{
					x=y;
					c--;
					break;
				}
			}
			if(x==1 && y==1)
				min=Math.min(min, c);
		}

		pw.println(min);

		pw.flush();
		pw.close();
	}

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			try {
				br = new BufferedReader(new FileReader(new File("alost.in")));
			} catch (FileNotFoundException e) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

import java.util.Scanner;

public class B {
    public static int getMin(int f,int s) {
        if(f==s) {
            if(f==1&&s==1) return 0;
            return 3000000;
        }
        int min=Math.min(f,s);
        int max=Math.max(f,s);
        if(min==0) return 3000000;;
        if(min==1) return max-1;
        return ((max/min))+getMin(max%min,min);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if(n==1){
            System.out.println(0); return;
        }
        int min=2*n;
        for(int i=1;i<=n/2;i++) {
            //System.out.println(getMin(i,n-i));
            min=Math.min(min,1+getMin(i,n-i));
        }
        System.out.println(min);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 1) {
                out.println(0);
                return;
            }
            int res = n - 1;
            for (int i = 1; i < n; i++) {
                res = Math.min(res, solOne(i, n));
            }
            out.println(res);
        }

        int solOne(int l, int r) {
            int res = 0;
            while (l != 1 || r != 1) {
                int d = Math.abs(l - r);
                if (d == 0) return Integer.MAX_VALUE;
                l = Math.min(l, r);
                r = d;
                res++;
            }
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int ans=100000000;
		for(int i=1;i<=n;i++)
		ans=Math.min(ans,Steps(i,n));
		System.out.print(ans);

	}
	public static int Steps(int x,int y)
	{
	    int count=0;
	    while(true)
	    {
	        if(x==1&&y==1)
	        return count;
	       else if(x<=0||y<=0)
	        return 100000000;
	        int max=Math.max(x,y);
	        int min=Math.min(x,y);
	        x=max-min;
	        y=min;
	        count++;
	    }
	   // return count;
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.ObjectInputStream.GetField;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

	public class Q1 {

		static long MOD = 1000000007;
		static boolean b[], b1[], check;
		static ArrayList<Integer>[] amp, pa;
		static ArrayList<Pair>[] amp1;
		static ArrayList<Pair>[][] damp;
		static int left[],s[],right[],sum[],dist[],cnt[],start[],color[],parent[],prime[],size[];
		static long ans = 0,k;
		static int p = 0;
		static FasterScanner sc = new FasterScanner(System.in);
		static Queue<Pair> queue = new LinkedList<>();
		static PriorityQueue<Integer> pq;
		static BufferedWriter log;
		static HashSet<Integer>[] hs;
		static HashMap<String,Integer> hm;
		static HashMap<Pair,Integer> hmp;
		static Stack<Integer> st;
		static boolean boo[][];
		static Pair prr[];
		static long parent1[],parent2[],size1[],size2[],arr1[],SUM[],MAX[];
		static int arr[];
		public static void main(String[] args) throws Exception {
	    	/*new Thread(null, new Runnable() {
				public void run() {
					try {
*/
						soln();
	/*				} catch (Exception e) {
						System.out.println(e);
					}
				}
			}, "1", 1 << 26).start();
		*/}
		static long dp[][];
		static int N,K;
		static HashMap<Pair,Integer> h = new HashMap<>();

		public static void soln() throws IOException {
			//FasterScanner in = new FasterScanner(new FileInputStream("C:\\Users\\Admin\\Desktop\\QCL.txt"));
			//PrintWriter out = new PrintWriter("C:\\Users\\Admin\\Desktop\\A1.txt");
			log = new BufferedWriter(new OutputStreamWriter(System.out));
			int n = sc.nextInt();
			N = n;
			if(n==1){
				System.out.println(0);
				return;
			}
			long fa = 100000000;
			for(int i = 1; i< n; i++){
				p =0;
				fa = Math.min(fa, recur(n,i));
			//	System.out.println(recur(n,i)+" "+i+" "+fa);
			}
			log.write(fa+"");
			log.close();
			//out.close();
		}
		static long and = Long.MAX_VALUE/2;
		static long recur(int n, int i){
			if(n==0 || i==0) return 10000000;
			if(n==1 || i==1){
				return Math.max(n, i)-1;
			}
			if(n==i){
				return 10000000;
			}
			if(n>=i){
				int y = n/i;
				p += (y+recur(n-y*i,i));
			}
			else{
				int y = i/n;
				p+=(y+recur(n,i-n*y));
			}
			return p;
		}
		static long comp(long n, long m){
			int l = Math.max(Long.toBinaryString(n).length(),Long.toBinaryString(m).length());
			System.out.println((m&(n^MAX[l]))+" "+(((m^MAX[l])&n)));
			return 2*((m&(n^MAX[l]))+(((m^MAX[l])&n)));
		}
		static void dfs2D(Pair p1){
			int i = p1.u, j = p1.v;
			boo[i][j] = true;
			amp1[p].add(p1);
			for(Pair pair : damp[i][j]){
				if(!boo[pair.u][pair.v]){
					dfs2D(pair);
				}
			}
		}
		static void recur(String str, int i, int n) throws IOException{
			//System.out.println(str+" "+i+" "+n);
			String s = str+(char)(i+'a')+"";
			if(n==N){
				log.write(s+"\n");
				return;
			}
			if(b[i]){
				for(int j = 0;j<26;j++){
					//System.out.println(1);
					if(!b[j] && j!=('y'-'a')){
						//System.out.println(1);
						recur(s,j,n+1);
					}
				}
			}
			else{
				for(int j = 0;j<26;j++){
					if(b[j]){
					//	System.out.println(2);
						recur(s,j,n+1);
					}
				}
			}
		}
		static void dfs(int x){
			long sum = 0, max = Long.MIN_VALUE;
			b[x] = true;
			//System.out.println(amp[x].size());
			PriorityQueue<Long> pq=new PriorityQueue<>(10,Collections.reverseOrder());
			if(amp[x].size()>2) check = true;
			for(int i:amp[x]){
				if(!b[i]){
					parent[i] = x;
					dfs(i);
					sum+=SUM[i];
					max = Math.max(max, MAX[i]);
					pq.add(MAX[i]);
				}
			}
			SUM[x] = sum+arr[x];
			MAX[x] = Math.max(SUM[x],max);
			if(pq.size()>=2){
				ans = Math.max(ans, pq.poll()+pq.poll());
			}

		}
		public static void buildWeightedGraph(int n){
			for(int i =0 ;i< n; i++){
				int x = sc.nextInt(), y = sc.nextInt(), w = sc.nextInt();
				amp1[--x].add(new Pair(--y,w));
				amp1[y].add(new Pair(x,w));
			}
		}

		public static void seive(int n){
			b = new boolean[(n+1)];
			Arrays.fill(b, true);
			b[1] = false;
			for(int i = 2;i*i<=n;i++){
				if(b[i]){
					for(int p = 2*i;p<=n;p+=i){
						b[p] = false;
					}
				}
			}
			/*for(int i = 2;i<=n;i++){
				if(b[i]) prime[i] = i;
			}*/
		}

		static class Graph{
			int vertex;
			int weight;
			Graph(int v, int w){
				vertex = v;
				weight = w;
			}
		}
		static class Pair implements Comparable<Pair> {
			int u;
			int v;
			public Pair(int u, int v) {
				this.u = u;
				this.v = v;
			}

			public int hashCode() {
				int hu = (int) (u ^ (u >>> 32));
				int hv = (int) (v ^ (v >>> 32));
				return 31*hu + hv;
			}

			public boolean equals(Object o) {
				Pair other = (Pair) o;
				return ((u == other.u && v == other.v));
			}

			public int compareTo(Pair other) {
				return Long.compare(u, other.u)!= 0 ? (Long.compare(u, other.u)) : (Long.compare(v, other.v));
			}

			public String toString() {
				return "[u=" + u + ", v=" + v + "]";
			}
		}

		public static void buildGraph(int n){
			for(int i =0;i<n;i++){
				int x = sc.nextInt()-1, y = sc.nextInt()-1;
				amp[x].add(y);
				amp[y].add(x);
			}
		}

		public static int getParent(long x){
			while(parent[(int) x]!=x){
				parent[ (int) x] = parent[(int) parent[ (int) x]];
				x = parent[ (int) x];
			}
			return (int) x;
		}
		static long min(long a, long b, long c){
			if(a<b && a<c) return a;
			if(b<c) return b;
			return c;
		}
		/*

		static class Pair3{
			int x, y ,z;
			Pair3(int x, int y, int z){
				this.x = x;
				this.y = y;
				this.z = z;
			}
		}*/
		static int sum(int n){
			String str = Integer.toString(n);
			int cnt = 0;
			for(int i = 0; i< str.length();i++){
				cnt+=(str.charAt(i)-'0');
			}
			return cnt;
		}
		 static void KMPSearch(String pat, String txt)
		    {
		        int M = pat.length();
		        int N = txt.length();

		        // create lps[] that will hold the longest
		        // prefix suffix values for pattern
		        int lps[] = new int[M];
		        int j = 0;  // index for pat[]

		        // Preprocess the pattern (calculate lps[]
		        // array)
		        computeLPSArray(pat,M,lps);

		        int i = 0;  // index for txt[]
		        while (i < N)
		        {
		            if (pat.charAt(j) == txt.charAt(i))
		            {
		                j++;
		                i++;
		            }
		            if (j == M)
		            {
		               // parent.add((i-j));
		                j = lps[j-1];
		            }

		            // mismatch after j matches
		            else if (i < N && pat.charAt(j) != txt.charAt(i))
		            {
		                // Do not match lps[0..lps[j-1]] characters,
		                // they will match anyway
		                if (j != 0)
		                    j = lps[j-1];
		                else
		                    i = i+1;
		            }
		        }
		    }
		 static void computeLPSArray(String pat, int M, int lps[])
		    {
		        // length of the previous longest prefix suffix
		        int len = 0;
		        int i = 1;
		        lps[0] = 0;  // lps[0] is always 0

		        // the loop calculates lps[i] for i = 1 to M-1
		        while (i < M)
		        {
		            if (pat.charAt(i) == pat.charAt(len))
		            {
		                len++;
		                lps[i] = len;
		                i++;
		            }
		            else  // (pat[i] != pat[len])
		            {
		                // This is tricky. Consider the example.
		                // AAACAAAA and i = 7. The idea is similar
		                // to search step.
		                if (len != 0)
		                {
		                    len = lps[len-1];

		                    // Also, note that we do not increment
		                    // i here
		                }
		                else  // if (len == 0)
		                {
		                    lps[i] = len;
		                    i++;
		                }
		            }
		        }
		    }
		private static void permutation(String prefix, String str) {
		    int n = str.length();
		    if (n == 0); //hs.add(prefix);
		    else {
		        for (int i = 0; i < n; i++)
		            permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1, n));
		    }
		}
		public static char give(char c1,char c2){
			if(c1!='a' && c2!='a') return 'a';
			if(c1!='b' && c2!='b') return 'b';
			return 'c';
		}

		public static void buildTree(int n){
			int arr[] = sc.nextIntArray(n);
			for(int i = 0;i<n;i++){
				int x = arr[i]-1;
				amp[i+1].add(x);
				amp[x].add(i+1);
			}
		}

		static class SegmentTree {
			boolean st[];
			boolean lazy[];

			SegmentTree(int n) {
				int size = 4 * n;
				st = new boolean[size];
				Arrays.fill(st, true);
				lazy = new boolean[size];
				Arrays.fill(lazy, true);
				//build(0, n - 1, 1);
			}

			/*long[] build(int ss, int se, int si) {
				if (ss == se) {
					st[si][0] = 1;
					st[si][1] = 1;
					st[si][2] = 1;
					return st[si];
				}
				int mid = (ss + se) / 2;
				long a1[] = build(ss, mid, si * 2), a2[] = build(mid + 1, se,
						si * 2 + 1);
				long ans[] = new long[3];
				if (arr[mid] < arr[mid + 1]) {
					ans[1] = Math.max(a2[1], Math.max(a1[1], a1[2] + a2[0]));
					if (a1[1] == (mid - ss + 1))
						ans[0] = ans[1];
					else
						ans[0] = a1[0];
					if (a2[2] == (se - mid))
						ans[2] = ans[1];
					else
						ans[2] = a2[2];
				} else {
					ans[1] = Math.max(a1[1], a2[1]);
					ans[0] = a1[0];
					ans[2] = a2[2];
				}
				st[si] = ans;
				return st[si];
			}*/

			void update(int si, int ss, int se, int idx, long x) {
				if (ss == se) {
					//arr[idx] += val;
					st[si]=false;
				}
				else {
					int mid = (ss + se) / 2;
					if(ss <= idx && idx <= mid)
			        {
			             update(2*si, ss, mid, idx, x);
			        }
			        else
			        { update(2*si+1, mid+1, se, idx, x);
			        }
					st[si] = st[2*si]|st[2*si+1];
				}
			}
			/*boolean get(int qs, int qe, int ss, int se, int si){
				if(qs>se || qe<ss) return 0;
				if (qs <= ss && qe >= se) {
					return st[si];
				}
				int mid = (ss+se)/2;
				return get(qs, qe, ss, mid, si * 2)+get(qs, qe, mid + 1, se, si * 2 + 1);
			}*/
			void updateRange(int node, int start, int end, int l, int r, boolean val)
			{
			    if(!lazy[node])
			    {
			        // This node needs to be updated
			        st[node] = lazy[node];    // Update it
			        if(start != end)
			        {
			            lazy[node*2] = lazy[node];                  // Mark child as lazy
			            lazy[node*2+1] = lazy[node];                // Mark child as lazy
			        }
			        lazy[node] = true;                                  // Reset it
			    }
			    if(start > end || start > r || end < l)              // Current segment is not within range [l, r]
			        return;
			    if(start >= l && end <= r)
			    {
			        // Segment is fully within range
			        st[node] =  val;
			        if(start != end)
			        {
			            // Not leaf node
			            lazy[node*2] = val;
			            lazy[node*2+1] = val;
			        }
			        return;
			    }
			    int mid = (start + end) / 2;
			    updateRange(node*2, start, mid, l, r, val);        // Updating left child
			    updateRange(node*2 + 1, mid + 1, end, l, r, val);   // Updating right child
			    st[node] = st[node*2] | st[node*2+1];        // Updating root with max value
			}

			boolean queryRange(int node, int start, int end, int l, int r)
			{
			    if(start > end || start > r || end < l)
			        return false;         // Out of range
			    if(!lazy[node])
			    {
			        // This node needs to be updated
			        st[node] = lazy[node];            // Update it
			        if(start != end)
			        {
			            lazy[node*2] = lazy[node];         // Mark child as lazy
			            lazy[node*2+1] = lazy[node];    // Mark child as lazy
			        }
			        lazy[node] = true;                 // Reset it
			    }
			    if(start >= l && end <= r)             // Current segment is totally within range [l, r]
			        return  st[node];
			    int mid = (start + end) / 2;
			    boolean p1 = queryRange(node*2, start, mid, l, r);         // Query left child
			    boolean b = queryRange(node*2 + 1, mid + 1, end, l, r); // Query right child
			    return (p1 | b);
			}
			void print() {
				for (int i = 0; i < st.length; i++) {
					System.out.print(st[i]+" ");
				}
				System.out.println();
			}
		}
		static int convert(int x){
			int cnt = 0;
			String str = Integer.toBinaryString(x);
			//System.out.println(str);
			for(int i = 0;i<str.length();i++){
				if(str.charAt(i)=='1'){
					cnt++;
				}
			}
			int ans = (int) Math.pow(3, 6-cnt);
			return ans;
		}
		static class Node2{
			Node2 left = null;
			Node2 right = null;
			Node2 parent = null;
			int data;
		}
		static class BinarySearchTree{
			Node2 root = null;
			int height = 0;
			int max = 0;
			int cnt = 1;
			ArrayList<Integer> parent = new ArrayList<>();
			HashMap<Integer, Integer> hm = new HashMap<>();
			public void insert(int x){
				Node2 n = new Node2();
				n.data = x;
				if(root==null){
					root = n;
				}
				else{
					Node2 temp = root,temb = null;
					while(temp!=null){
						temb = temp;
						if(x>temp.data) temp = temp.right;
						else temp = temp.left;
					}
					if(x>temb.data) temb.right = n;
					else temb.left = n;
					n.parent = temb;
					parent.add(temb.data);
				}
			}
			public Node2 getSomething(int x, int y, Node2 n){
				if(n.data==x || n.data==y) return n;
				else if(n.data>x && n.data<y) return n;
				else if(n.data<x && n.data<y) return getSomething(x,y,n.right);
				else return getSomething(x,y,n.left);
			}
			public Node2 search(int x,Node2 n){
				if(x==n.data){
					max = Math.max(max, n.data);
					return n;
				}
				if(x>n.data){
					max = Math.max(max, n.data);
					return search(x,n.right);
				}
				else{
					max = Math.max(max, n.data);
					return search(x,n.left);
				}
			}
			public int getHeight(Node2 n){
				if(n==null) return 0;
				height = 1+ Math.max(getHeight(n.left), getHeight(n.right));
				return height;
			}
		}
		static long findDiff(long[] arr, long[] brr, int m){
			int i = 0, j = 0;
			long fa = 1000000000000L;
			while(i<m && j<m){
				long x = arr[i]-brr[j];
				if(x>=0){
					if(x<fa) fa = x;
					j++;
				}
				else{
					if((-x)<fa) fa = -x;
					i++;
				}
			}
			return fa;
		}
		public static long max(long x, long y, long z){
			if(x>=y && x>=z) return x;
			if(y>=x && y>=z) return y;
			return z;
		}

		static long modInverse(long a, long mOD2){
		            return  power(a, mOD2-2, mOD2);
		}
		static long power(long x, long y, long m)
		{
		    if (y == 0)
		        return 1;
		    long p = power(x, y/2, m) % m;
		    p = (p * p) % m;

		    return (y%2 == 0)? p : (x * p) % m;
		}
		static long power2(long x,BigInteger y,long m){
			long ans = 1;
			BigInteger two = new BigInteger("2");
			while(y.compareTo(BigInteger.ZERO)>0){
				if(y.getLowestSetBit()==y.bitCount()){
					x = (x*x)%MOD;
					y = y.divide(two);
				}
				else{
					ans = (ans*x)%MOD;
					y = y.subtract(BigInteger.ONE);
				}
			}
			return ans;
		}
		static BigInteger power2(BigInteger x, BigInteger y, BigInteger m){
			BigInteger ans = new BigInteger("1");
			BigInteger one  = new BigInteger("1");
			BigInteger two  = new BigInteger("2");
			BigInteger zero  = new BigInteger("0");
			while(y.compareTo(zero)>0){
				//System.out.println(y);
				if(y.mod(two).equals(one)){
					ans = ans.multiply(x).mod(m);
					y = y.subtract(one);
				}
				else{
					x = x.multiply(x).mod(m);
					y = y.divide(two);
				}
			}
			return ans;
		}
		static BigInteger power(BigInteger x, BigInteger y, BigInteger m)
		{
		    if (y.equals(0))
		        return (new BigInteger("1"));
		    BigInteger p = power(x, y.divide(new BigInteger("2")), m).mod(m);
		    p = (p.multiply(p)).mod(m);

		    return (y.mod(new BigInteger("2")).equals(0))? p : (p.multiply(x)).mod(m);
		}
		static long d,x,y;
		public static void extendedEuclidian(long a, long b){
			if(b == 0) {
		        d = a;
		        x = 1;
		        y = 0;
		    }
		    else {
		        extendedEuclidian(b, a%b);
		        int temp = (int) x;
		        x = y;
		        y = temp - (a/b)*y;
		    }
		}

		public static long gcd(long n, long m){
			if(m!=0) return gcd(m,n%m);
			else return n;
		}

		static BufferedReader reader;
	    static StringTokenizer tokenizer;
	    static PrintWriter writer;

	    static class FasterScanner {

			private final InputStream stream;
			private final byte[] buf = new byte[8192];
			private int curChar, snumChars;
			private SpaceCharFilter filter;

			public FasterScanner(InputStream stream) {
				this.stream = stream;
			}

			public int snext() {
				if (snumChars == -1)
					throw new InputMismatchException();
				if (curChar >= snumChars) {
					curChar = 0;
					try {
						snumChars = stream.read(buf);
					} catch (IOException e) {
						throw new InputMismatchException();
					}
					if (snumChars <= 0)
						return -1;
				}
				return buf[curChar++];
			}

			public int nextInt() {
				int c = snext();
				while (isSpaceChar(c)) {
					c = snext();
				}
				int sgn = 1;
				if (c == '-') {
					sgn = -1;
					c = snext();
				}
				int res = 0;
				do {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public long nextLong() {
				int c = snext();
				while (isSpaceChar(c)) {
					c = snext();
				}
				int sgn = 1;
				if (c == '-') {
					sgn = -1;
					c = snext();
				}
				long res = 0;
				do {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public int[] nextIntArray(int n) {
				int a[] = new int[n];
				for (int i = 0; i < n; i++) {
					a[i] = nextInt();
				}
				return a;
			}

			public long[] nextLongArray(int n) {
				long a[] = new long[n];
				for (int i = 0; i < n; i++) {
					a[i] = nextInt();
				}
				return a;
			}

			public String readString() {
				int c = snext();
				while (isSpaceChar(c)) {
					c = snext();
				}
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = snext();
				} while (!isSpaceChar(c));
				return res.toString();
			}

			public String nextLine() {
				int c = snext();
				while (isSpaceChar(c))
					c = snext();
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = snext();
				} while (!isEndOfLine(c));
				return res.toString();
			}

			public boolean isSpaceChar(int c) {
				if (filter != null)
					return filter.isSpaceChar(c);
				return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}

			private boolean isEndOfLine(int c) {
				return c == '\n' || c == '\r' || c == -1;
			}

			public interface SpaceCharFilter {
				public boolean isSpaceChar(int ch);
			}
		}
	}

/**
 * @author Juan Sebastian Beltran Rojas
 * @mail jsbeltran.valhalla@gmail.com
 * @veredict No enviado
 * @problemId 134B
 * @problemName Pairs of Numbers
 * @judge http://www.codeforces.com/
 * @category math
 * @level easy
 * @date 01/08/2012
 **/
import java.io.*;
import static java.lang.Integer.*;
import static java.lang.Math.*;
public class CF134B{
	static int f(int a,int b){
		int c;
		if(a==1||b==1)return max(a,b)-1;
		if(a>b&&a%b!=0&&(c=f(a%b,b))!=MAX_VALUE)return c+a/b;
		if(b>a&&b%a!=0&&(c=f(a,b%a))!=MAX_VALUE)return c+b/a;
		return MAX_VALUE;
	}
	public static void main(String args[]) throws Throwable{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		int n=parseInt(in.readLine()),r=MAX_VALUE;
		for(int i=1;i<=n;i++)r=min(r,f(n,i));
		System.out.println(r);
	}
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main//saw editorial
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////
    static int n;
    public static int dfs(int a,int b)
    {
        int count=0;
        while(true)
        {
            if(a<1||b<1)
            return 100000000;
            else if(a==1&&b==1)
            return count;
            count++;
            if(a>b)
            a-=b;
            else
            b-=a;
        }
    }
    public static void main(String[] args)throws IOException
    {
        PrintStream out= new PrintStream(System.out);
        Reader sc=new Reader();
        n=sc.i();
        int ans=1000000000;
        for(int i=1;i<=n;i++)
        ans=Math.min(ans,dfs(i,n));

        System.out.println(ans);
        out.flush();
    }
}

import java.util.*;
import java.io.*;

public class Main {
   public static void main(String[] args) throws Exception {
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
      int n             = Integer.parseInt(bf.readLine());

      if (n == 1) {
         System.out.println(0);
         return;
      }
      int best = Integer.MAX_VALUE;

      for (int i = 1; i < n; i++) {
         int a   = i;
         int b   = n;
         int ans = 0;

         while (a > 1) {
            ans += b / a;
            b   %= a;
            int tmp = a;
            a = b;
            b = tmp;
         }

         if (a == 1) best = Math.min(best, ans + (b - a));
      }
      System.out.println(best);
   }
}

import java.io.*;
import java.util.*;
public class B134
{
    int x,y;
    public B134(int xx,int yy)
    {
        this.x=xx;
        this.y=yy;
    }

    static int INF= 1000000;
    public static void  main(String[] args)
    {
        Scanner sc = new Scanner (new BufferedReader(new InputStreamReader(System.in)));
        int n;
        n = sc.nextInt();
        int min = INF;
        for (int i = 1; i <= n; i++){
            min=Math.min(min,path(n, i));

        }
        System.out.println(min);
    }
    public static int path(int a, int b){
        if (b == 0) return INF;
        if (b == 1) return a - 1;
        return path(b, a%b) + a / b;
    }

}

import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;

public class b3 {
    public static void debug(Object... obs) {
        System.out.println(Arrays.deepToString(obs));
    }

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int ming = n - 1;
        for (int i = 2; i < n; i++) {
            if (n % i == 0)
                continue;
            int a = Math.max(n, i);
            int b = Math.min(n, i);
            int cnt = 0;
            while (b > 1) {
                if (a % b == 0) {
                    cnt = 1000;
                    break;
                }
                int tmp1 = Math.min(a, b);
                int tmp2 = Math.max(a, b);

                a = Math.max(tmp1, tmp2 - tmp1);
                b = Math.min(tmp1, tmp2 - tmp1);
                cnt++;
            }
            cnt += a - 1;

            //debug(n, i, cnt);
            ming = Math.min(ming, cnt);
        }
        System.out.println(ming);
    }
}

import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int a, b;
        int ans = n - 1;
        for (int i = 1; i < (n + 1) / 2; i++) {
            int t = 1;
            a = i;
            b = n - i;
            while (true) {
                if (a == 1) {
                    t = t + b - 1;
                    break;
                } else if (a == 0) {
                    t = n - 1;
                    break;
                }
                t += b / a;
                b = b % a;
                int c = a;
                a = b;
                b = c;
            }
            if (t < ans) {
                ans = t;
            }
        }
        System.out.println(ans);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		StreamInputReader in = new StreamInputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, StreamInputReader in, OutputWriter out) {
        int n = in.readInt();
        int res = n-1;
        for(int i = 1; i < n; ++i) {
            res = Math.min(res, solve(i, n));
        }
        out.printLine(res);
	}
    private int solve(int a,int b) {
        int steps = 0;
        while (a >= 1 && b >= 1 && a != b) {
            if (a < b) b -= a;
            else a -=b;
            ++steps;
        }
        if (a == 1 && b == 1) {
            return steps;
        }
        return 10000000;
    }
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    }

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(outputStream);
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}
}

abstract class InputReader {

	public abstract int read();

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    protected boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class TestClass {
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;

	static long x;
	public static boolean check(long p,long q){
		if((x-q)%p==0)
			return true;
		return false;
	}
	private static void soln(){
		long n = 1;
		long m = 1;
		long ans = 0;
		x = nI();
		boolean v = false;
		while(n+m!=x){
			long nm = Math.max(m, n);
			n = Math.min(m, n);
			m = nm;
			if(check(m,n))
				n+=m;
			else if(check(n,m))
				m+=n;
			ans++;
			if(n>x&&m>x){
				v = true;
				break;
			}
		}
		if(!v)
			pw.println(ans+1);
		else
			pw.println("0");
	}

	public static void main(String[] args) {
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}

	// To Get Input
	// Some Buffer Methods
	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}

	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private static int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private static int nI() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static long nL() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nLi() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class B134 {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        if (n == 1){
            System.out.println(0);
        } else if (n==2){
            System.out.println(1);
        } else if (n==3){
            System.out.println(2);
        } else {
            int m = n/2 + 1;
            if (m%2==0) ++m;
            int cnt=0;
            while(true){
                if (m>n){
                    m-=n;
                } else {
                    n-=m;
                }
                cnt++;
                if ((n==1||n==2)&&(m==1||m==2)) break;
            }
            if (n==2 || m==2){
                cnt++;
            }
            System.out.println(cnt);
        }
    }
}

import java.util.Scanner;

public class PairsOfNumbers {

    public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
   int n=in.nextInt();
   int x1=1,x2=1;
   int k=0;int y;
      while(x1!=n&&x2!=n)
      {k++;
      y=x1+x2;
             if(y+x1==n){x2=y;}else if(y+x2==n){x1=y;}else
             if((n%y)-x1==0){k+=n/y;break;}else
                 if((n%y)-x2==0){k+=n/y;break;} else
             if(x1>x2){x2=y;}else{x1=y;}
             if(x1>1&&x2>1)
             {if((n-x1)%x2==0){k+=(n-x1)/x2;break;}
             if((n-x2)%x1==0){k+=(n-x2)/x1;break;}
             }}
        System.out.println(k);
    }

}

import java.util.Scanner;

public class PairsOfNumbers {

    public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
   int n=in.nextInt();
   int x1=1,x2=1;
   int k=0;int y;
      while(x1!=n&&x2!=n)
      {k++;
      y=x1+x2;
             if(y+x1==n){x2=y;}else if(y+x2==n){x1=y;}else
             if(x1>x2){x2=y;}else{x1=y;}
             if(x1>1&&x2>1)
             {if((n-x1)%x2==0){k+=(n-x1)/x2;break;}
             if((n-x2)%x1==0){k+=(n-x2)/x1;break;}
             }}
        System.out.println(k);
    }

}

import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class A {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);

		int n=sc.nextInt();
		int c=0;
		int m1=1;
		int m2=1;
		while(m1<n){
			c++;
			m1+=m2;
			m2=m1-m2;
		}
		pw.println(c);
		pw.flush();
		pw.close();
	}

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			try {
				br = new BufferedReader(new FileReader(new File("alost.in")));
			} catch (FileNotFoundException e) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 1) {
                out.println(0);
                return;
            }
            int l = n / 2;
            int r = n - l;
            while ((l % 2 == 0 && r % 2 == 0) || (l == r && r != 1)) {
                l--;
                r++;
            }
            out.println(solOne(l, n));
        }

        int solOne(int l, int r) {
            int res = 0;
            while (l != 1 || r != 1) {
                int d = Math.abs(l - r);
                if (d == 0) return Integer.MAX_VALUE;
                l = Math.min(l, r);
                r = d;
                res++;
            }
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.ObjectInputStream.GetField;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

	public class Q1 {

		static long MOD = 1000000007;
		static boolean b[], b1[], check;
		static ArrayList<Integer>[] amp, pa;
		static ArrayList<Pair>[] amp1;
		static ArrayList<Pair>[][] damp;
		static int left[],s[],right[],sum[],dist[],cnt[],start[],color[],parent[],prime[],size[];
		static long ans = 0,k;
		static int p = 0;
		static FasterScanner sc = new FasterScanner(System.in);
		static Queue<Pair> queue = new LinkedList<>();
		static PriorityQueue<Integer> pq;
		static BufferedWriter log;
		static HashSet<Integer>[] hs;
		static HashMap<String,Integer> hm;
		static HashMap<Pair,Integer> hmp;
		static Stack<Integer> st;
		static boolean boo[][];
		static Pair prr[];
		static long parent1[],parent2[],size1[],size2[],arr1[],SUM[],MAX[];
		static int arr[];
		public static void main(String[] args) throws Exception {
	    	/*new Thread(null, new Runnable() {
				public void run() {
					try {
*/
						soln();
	/*				} catch (Exception e) {
						System.out.println(e);
					}
				}
			}, "1", 1 << 26).start();
		*/}
		static long dp[][];
		static int N,K;
		static HashMap<Pair,Integer> h = new HashMap<>();

		public static void soln() throws IOException {
			//FasterScanner in = new FasterScanner(new FileInputStream("C:\\Users\\Admin\\Desktop\\QCL.txt"));
			//PrintWriter out = new PrintWriter("C:\\Users\\Admin\\Desktop\\A1.txt");
			log = new BufferedWriter(new OutputStreamWriter(System.out));
			int n = sc.nextInt();
			int arr[] = new int[500];
			arr[0] = 1; arr[1] = 2;
			for(int i = 2; i< 500; i++){
				arr[i] = arr[i-1]+arr[i-2];
			}
			//System.out.println(arr[150]);
			for(int i =0 ; i< n; i++){
				if(arr[i]>=n){
					System.out.println(i);return;
				}
			}
			log.close();
			//out.close();
		}
		static long and = Long.MAX_VALUE/2;
		static void recur(int a, int b, int ans){
		//System.out.println(a+" "+b+" "+ans);
			if(a==N || b==N){
				and = Math.min(ans,and);
				return;
			}
			else if(a>N || b>N) return;
			if(h.containsKey(new Pair(a,b))) h.put(new Pair(a,b),Math.min(h.get(new Pair(a,b)), ans));
			recur(a,a+b,ans+1); recur(a+b,b,ans+1);
			h.put(new Pair(a,b), ans);
		}
		static long comp(long n, long m){
			int l = Math.max(Long.toBinaryString(n).length(),Long.toBinaryString(m).length());
			System.out.println((m&(n^MAX[l]))+" "+(((m^MAX[l])&n)));
			return 2*((m&(n^MAX[l]))+(((m^MAX[l])&n)));
		}
		static void dfs2D(Pair p1){
			int i = p1.u, j = p1.v;
			boo[i][j] = true;
			amp1[p].add(p1);
			for(Pair pair : damp[i][j]){
				if(!boo[pair.u][pair.v]){
					dfs2D(pair);
				}
			}
		}
		static void recur(String str, int i, int n) throws IOException{
			//System.out.println(str+" "+i+" "+n);
			String s = str+(char)(i+'a')+"";
			if(n==N){
				log.write(s+"\n");
				return;
			}
			if(b[i]){
				for(int j = 0;j<26;j++){
					//System.out.println(1);
					if(!b[j] && j!=('y'-'a')){
						//System.out.println(1);
						recur(s,j,n+1);
					}
				}
			}
			else{
				for(int j = 0;j<26;j++){
					if(b[j]){
					//	System.out.println(2);
						recur(s,j,n+1);
					}
				}
			}
		}
		static void dfs(int x){
			long sum = 0, max = Long.MIN_VALUE;
			b[x] = true;
			//System.out.println(amp[x].size());
			PriorityQueue<Long> pq=new PriorityQueue<>(10,Collections.reverseOrder());
			if(amp[x].size()>2) check = true;
			for(int i:amp[x]){
				if(!b[i]){
					parent[i] = x;
					dfs(i);
					sum+=SUM[i];
					max = Math.max(max, MAX[i]);
					pq.add(MAX[i]);
				}
			}
			SUM[x] = sum+arr[x];
			MAX[x] = Math.max(SUM[x],max);
			if(pq.size()>=2){
				ans = Math.max(ans, pq.poll()+pq.poll());
			}

		}
		public static void buildWeightedGraph(int n){
			for(int i =0 ;i< n; i++){
				int x = sc.nextInt(), y = sc.nextInt(), w = sc.nextInt();
				amp1[--x].add(new Pair(--y,w));
				amp1[y].add(new Pair(x,w));
			}
		}

		public static void seive(int n){
			b = new boolean[(n+1)];
			Arrays.fill(b, true);
			b[1] = false;
			for(int i = 2;i*i<=n;i++){
				if(b[i]){
					for(int p = 2*i;p<=n;p+=i){
						b[p] = false;
					}
				}
			}
			/*for(int i = 2;i<=n;i++){
				if(b[i]) prime[i] = i;
			}*/
		}

		static class Graph{
			int vertex;
			int weight;
			Graph(int v, int w){
				vertex = v;
				weight = w;
			}
		}
		static class Pair implements Comparable<Pair> {
			int u;
			int v;
			public Pair(int u, int v) {
				this.u = u;
				this.v = v;
			}

			public int hashCode() {
				int hu = (int) (u ^ (u >>> 32));
				int hv = (int) (v ^ (v >>> 32));
				return 31*hu + hv;
			}

			public boolean equals(Object o) {
				Pair other = (Pair) o;
				return ((u == other.u && v == other.v));
			}

			public int compareTo(Pair other) {
				return Long.compare(u, other.u)!= 0 ? (Long.compare(u, other.u)) : (Long.compare(v, other.v));
			}

			public String toString() {
				return "[u=" + u + ", v=" + v + "]";
			}
		}

		public static void buildGraph(int n){
			for(int i =0;i<n;i++){
				int x = sc.nextInt()-1, y = sc.nextInt()-1;
				amp[x].add(y);
				amp[y].add(x);
			}
		}

		public static int getParent(long x){
			while(parent[(int) x]!=x){
				parent[ (int) x] = parent[(int) parent[ (int) x]];
				x = parent[ (int) x];
			}
			return (int) x;
		}
		static long min(long a, long b, long c){
			if(a<b && a<c) return a;
			if(b<c) return b;
			return c;
		}
		/*

		static class Pair3{
			int x, y ,z;
			Pair3(int x, int y, int z){
				this.x = x;
				this.y = y;
				this.z = z;
			}
		}*/
		static int sum(int n){
			String str = Integer.toString(n);
			int cnt = 0;
			for(int i = 0; i< str.length();i++){
				cnt+=(str.charAt(i)-'0');
			}
			return cnt;
		}
		 static void KMPSearch(String pat, String txt)
		    {
		        int M = pat.length();
		        int N = txt.length();

		        // create lps[] that will hold the longest
		        // prefix suffix values for pattern
		        int lps[] = new int[M];
		        int j = 0;  // index for pat[]

		        // Preprocess the pattern (calculate lps[]
		        // array)
		        computeLPSArray(pat,M,lps);

		        int i = 0;  // index for txt[]
		        while (i < N)
		        {
		            if (pat.charAt(j) == txt.charAt(i))
		            {
		                j++;
		                i++;
		            }
		            if (j == M)
		            {
		               // parent.add((i-j));
		                j = lps[j-1];
		            }

		            // mismatch after j matches
		            else if (i < N && pat.charAt(j) != txt.charAt(i))
		            {
		                // Do not match lps[0..lps[j-1]] characters,
		                // they will match anyway
		                if (j != 0)
		                    j = lps[j-1];
		                else
		                    i = i+1;
		            }
		        }
		    }
		 static void computeLPSArray(String pat, int M, int lps[])
		    {
		        // length of the previous longest prefix suffix
		        int len = 0;
		        int i = 1;
		        lps[0] = 0;  // lps[0] is always 0

		        // the loop calculates lps[i] for i = 1 to M-1
		        while (i < M)
		        {
		            if (pat.charAt(i) == pat.charAt(len))
		            {
		                len++;
		                lps[i] = len;
		                i++;
		            }
		            else  // (pat[i] != pat[len])
		            {
		                // This is tricky. Consider the example.
		                // AAACAAAA and i = 7. The idea is similar
		                // to search step.
		                if (len != 0)
		                {
		                    len = lps[len-1];

		                    // Also, note that we do not increment
		                    // i here
		                }
		                else  // if (len == 0)
		                {
		                    lps[i] = len;
		                    i++;
		                }
		            }
		        }
		    }
		private static void permutation(String prefix, String str) {
		    int n = str.length();
		    if (n == 0); //hs.add(prefix);
		    else {
		        for (int i = 0; i < n; i++)
		            permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1, n));
		    }
		}
		public static char give(char c1,char c2){
			if(c1!='a' && c2!='a') return 'a';
			if(c1!='b' && c2!='b') return 'b';
			return 'c';
		}

		public static void buildTree(int n){
			int arr[] = sc.nextIntArray(n);
			for(int i = 0;i<n;i++){
				int x = arr[i]-1;
				amp[i+1].add(x);
				amp[x].add(i+1);
			}
		}

		static class SegmentTree {
			boolean st[];
			boolean lazy[];

			SegmentTree(int n) {
				int size = 4 * n;
				st = new boolean[size];
				Arrays.fill(st, true);
				lazy = new boolean[size];
				Arrays.fill(lazy, true);
				//build(0, n - 1, 1);
			}

			/*long[] build(int ss, int se, int si) {
				if (ss == se) {
					st[si][0] = 1;
					st[si][1] = 1;
					st[si][2] = 1;
					return st[si];
				}
				int mid = (ss + se) / 2;
				long a1[] = build(ss, mid, si * 2), a2[] = build(mid + 1, se,
						si * 2 + 1);
				long ans[] = new long[3];
				if (arr[mid] < arr[mid + 1]) {
					ans[1] = Math.max(a2[1], Math.max(a1[1], a1[2] + a2[0]));
					if (a1[1] == (mid - ss + 1))
						ans[0] = ans[1];
					else
						ans[0] = a1[0];
					if (a2[2] == (se - mid))
						ans[2] = ans[1];
					else
						ans[2] = a2[2];
				} else {
					ans[1] = Math.max(a1[1], a2[1]);
					ans[0] = a1[0];
					ans[2] = a2[2];
				}
				st[si] = ans;
				return st[si];
			}*/

			void update(int si, int ss, int se, int idx, long x) {
				if (ss == se) {
					//arr[idx] += val;
					st[si]=false;
				}
				else {
					int mid = (ss + se) / 2;
					if(ss <= idx && idx <= mid)
			        {
			             update(2*si, ss, mid, idx, x);
			        }
			        else
			        { update(2*si+1, mid+1, se, idx, x);
			        }
					st[si] = st[2*si]|st[2*si+1];
				}
			}
			/*boolean get(int qs, int qe, int ss, int se, int si){
				if(qs>se || qe<ss) return 0;
				if (qs <= ss && qe >= se) {
					return st[si];
				}
				int mid = (ss+se)/2;
				return get(qs, qe, ss, mid, si * 2)+get(qs, qe, mid + 1, se, si * 2 + 1);
			}*/
			void updateRange(int node, int start, int end, int l, int r, boolean val)
			{
			    if(!lazy[node])
			    {
			        // This node needs to be updated
			        st[node] = lazy[node];    // Update it
			        if(start != end)
			        {
			            lazy[node*2] = lazy[node];                  // Mark child as lazy
			            lazy[node*2+1] = lazy[node];                // Mark child as lazy
			        }
			        lazy[node] = true;                                  // Reset it
			    }
			    if(start > end || start > r || end < l)              // Current segment is not within range [l, r]
			        return;
			    if(start >= l && end <= r)
			    {
			        // Segment is fully within range
			        st[node] =  val;
			        if(start != end)
			        {
			            // Not leaf node
			            lazy[node*2] = val;
			            lazy[node*2+1] = val;
			        }
			        return;
			    }
			    int mid = (start + end) / 2;
			    updateRange(node*2, start, mid, l, r, val);        // Updating left child
			    updateRange(node*2 + 1, mid + 1, end, l, r, val);   // Updating right child
			    st[node] = st[node*2] | st[node*2+1];        // Updating root with max value
			}

			boolean queryRange(int node, int start, int end, int l, int r)
			{
			    if(start > end || start > r || end < l)
			        return false;         // Out of range
			    if(!lazy[node])
			    {
			        // This node needs to be updated
			        st[node] = lazy[node];            // Update it
			        if(start != end)
			        {
			            lazy[node*2] = lazy[node];         // Mark child as lazy
			            lazy[node*2+1] = lazy[node];    // Mark child as lazy
			        }
			        lazy[node] = true;                 // Reset it
			    }
			    if(start >= l && end <= r)             // Current segment is totally within range [l, r]
			        return  st[node];
			    int mid = (start + end) / 2;
			    boolean p1 = queryRange(node*2, start, mid, l, r);         // Query left child
			    boolean b = queryRange(node*2 + 1, mid + 1, end, l, r); // Query right child
			    return (p1 | b);
			}
			void print() {
				for (int i = 0; i < st.length; i++) {
					System.out.print(st[i]+" ");
				}
				System.out.println();
			}
		}
		static int convert(int x){
			int cnt = 0;
			String str = Integer.toBinaryString(x);
			//System.out.println(str);
			for(int i = 0;i<str.length();i++){
				if(str.charAt(i)=='1'){
					cnt++;
				}
			}
			int ans = (int) Math.pow(3, 6-cnt);
			return ans;
		}
		static class Node2{
			Node2 left = null;
			Node2 right = null;
			Node2 parent = null;
			int data;
		}
		static class BinarySearchTree{
			Node2 root = null;
			int height = 0;
			int max = 0;
			int cnt = 1;
			ArrayList<Integer> parent = new ArrayList<>();
			HashMap<Integer, Integer> hm = new HashMap<>();
			public void insert(int x){
				Node2 n = new Node2();
				n.data = x;
				if(root==null){
					root = n;
				}
				else{
					Node2 temp = root,temb = null;
					while(temp!=null){
						temb = temp;
						if(x>temp.data) temp = temp.right;
						else temp = temp.left;
					}
					if(x>temb.data) temb.right = n;
					else temb.left = n;
					n.parent = temb;
					parent.add(temb.data);
				}
			}
			public Node2 getSomething(int x, int y, Node2 n){
				if(n.data==x || n.data==y) return n;
				else if(n.data>x && n.data<y) return n;
				else if(n.data<x && n.data<y) return getSomething(x,y,n.right);
				else return getSomething(x,y,n.left);
			}
			public Node2 search(int x,Node2 n){
				if(x==n.data){
					max = Math.max(max, n.data);
					return n;
				}
				if(x>n.data){
					max = Math.max(max, n.data);
					return search(x,n.right);
				}
				else{
					max = Math.max(max, n.data);
					return search(x,n.left);
				}
			}
			public int getHeight(Node2 n){
				if(n==null) return 0;
				height = 1+ Math.max(getHeight(n.left), getHeight(n.right));
				return height;
			}
		}
		static long findDiff(long[] arr, long[] brr, int m){
			int i = 0, j = 0;
			long fa = 1000000000000L;
			while(i<m && j<m){
				long x = arr[i]-brr[j];
				if(x>=0){
					if(x<fa) fa = x;
					j++;
				}
				else{
					if((-x)<fa) fa = -x;
					i++;
				}
			}
			return fa;
		}
		public static long max(long x, long y, long z){
			if(x>=y && x>=z) return x;
			if(y>=x && y>=z) return y;
			return z;
		}

		static long modInverse(long a, long mOD2){
		            return  power(a, mOD2-2, mOD2);
		}
		static long power(long x, long y, long m)
		{
		    if (y == 0)
		        return 1;
		    long p = power(x, y/2, m) % m;
		    p = (p * p) % m;

		    return (y%2 == 0)? p : (x * p) % m;
		}
		static long power2(long x,BigInteger y,long m){
			long ans = 1;
			BigInteger two = new BigInteger("2");
			while(y.compareTo(BigInteger.ZERO)>0){
				if(y.getLowestSetBit()==y.bitCount()){
					x = (x*x)%MOD;
					y = y.divide(two);
				}
				else{
					ans = (ans*x)%MOD;
					y = y.subtract(BigInteger.ONE);
				}
			}
			return ans;
		}
		static BigInteger power2(BigInteger x, BigInteger y, BigInteger m){
			BigInteger ans = new BigInteger("1");
			BigInteger one  = new BigInteger("1");
			BigInteger two  = new BigInteger("2");
			BigInteger zero  = new BigInteger("0");
			while(y.compareTo(zero)>0){
				//System.out.println(y);
				if(y.mod(two).equals(one)){
					ans = ans.multiply(x).mod(m);
					y = y.subtract(one);
				}
				else{
					x = x.multiply(x).mod(m);
					y = y.divide(two);
				}
			}
			return ans;
		}
		static BigInteger power(BigInteger x, BigInteger y, BigInteger m)
		{
		    if (y.equals(0))
		        return (new BigInteger("1"));
		    BigInteger p = power(x, y.divide(new BigInteger("2")), m).mod(m);
		    p = (p.multiply(p)).mod(m);

		    return (y.mod(new BigInteger("2")).equals(0))? p : (p.multiply(x)).mod(m);
		}
		static long d,x,y;
		public static void extendedEuclidian(long a, long b){
			if(b == 0) {
		        d = a;
		        x = 1;
		        y = 0;
		    }
		    else {
		        extendedEuclidian(b, a%b);
		        int temp = (int) x;
		        x = y;
		        y = temp - (a/b)*y;
		    }
		}

		public static long gcd(long n, long m){
			if(m!=0) return gcd(m,n%m);
			else return n;
		}

		static BufferedReader reader;
	    static StringTokenizer tokenizer;
	    static PrintWriter writer;

	    static class FasterScanner {

			private final InputStream stream;
			private final byte[] buf = new byte[8192];
			private int curChar, snumChars;
			private SpaceCharFilter filter;

			public FasterScanner(InputStream stream) {
				this.stream = stream;
			}

			public int snext() {
				if (snumChars == -1)
					throw new InputMismatchException();
				if (curChar >= snumChars) {
					curChar = 0;
					try {
						snumChars = stream.read(buf);
					} catch (IOException e) {
						throw new InputMismatchException();
					}
					if (snumChars <= 0)
						return -1;
				}
				return buf[curChar++];
			}

			public int nextInt() {
				int c = snext();
				while (isSpaceChar(c)) {
					c = snext();
				}
				int sgn = 1;
				if (c == '-') {
					sgn = -1;
					c = snext();
				}
				int res = 0;
				do {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public long nextLong() {
				int c = snext();
				while (isSpaceChar(c)) {
					c = snext();
				}
				int sgn = 1;
				if (c == '-') {
					sgn = -1;
					c = snext();
				}
				long res = 0;
				do {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public int[] nextIntArray(int n) {
				int a[] = new int[n];
				for (int i = 0; i < n; i++) {
					a[i] = nextInt();
				}
				return a;
			}

			public long[] nextLongArray(int n) {
				long a[] = new long[n];
				for (int i = 0; i < n; i++) {
					a[i] = nextInt();
				}
				return a;
			}

			public String readString() {
				int c = snext();
				while (isSpaceChar(c)) {
					c = snext();
				}
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = snext();
				} while (!isSpaceChar(c));
				return res.toString();
			}

			public String nextLine() {
				int c = snext();
				while (isSpaceChar(c))
					c = snext();
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = snext();
				} while (!isEndOfLine(c));
				return res.toString();
			}

			public boolean isSpaceChar(int c) {
				if (filter != null)
					return filter.isSpaceChar(c);
				return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}

			private boolean isEndOfLine(int c) {
				return c == '\n' || c == '\r' || c == -1;
			}

			public interface SpaceCharFilter {
				public boolean isSpaceChar(int ch);
			}
		}
	}

import java.util.*;
import java.io.*;

public class Main {
   public static void main(String[] args) throws Exception {
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
      int n             = Integer.parseInt(bf.readLine());

      if (n == 1) {
         System.out.println(1);
         return;
      }
      int best = Integer.MAX_VALUE;

      for (int i = 1; i < n; i++) {
         int a   = i;
         int b   = n;
         int ans = 0;

         while (a > 1) {
            ans += b / a;
            b   %= a;
            int tmp = a;
            a = b;
            b = tmp;
         }

         if (a == 1) best = Math.min(best, ans + (b - a));
      }
      System.out.println(best);
   }
}

import java.io.*;
import java.util.*;
public class B134
{
    int x,y;
    public B134(int xx,int yy)
    {
        this.x=xx;
        this.y=yy;
    }
    public static void main(String args[])throws IOException
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int c=1,cc=0,lvl=0;
        Queue<B134> q=new LinkedList<>();
        q.add(new B134(1,1));
        if(n==1)
            System.out.println(0);
        else
        {
        while(q.size()!=0)
        {
            B134 ob=q.poll();
            int xx=ob.x,yy=ob.y;
            c--;
            if(xx+yy==n)
                break;
            q.add(new B134(xx,xx+yy));
            q.add(new B134(xx+yy,yy));
            cc+=2;
            if(c==0)
            {
                c=cc;
                lvl++;
            }
        }
        System.out.println(lvl+1);
        }
    }
}

import java.io.*;
import java.util.*;

public class cf134b {
  public static void main(String[] args) {
    FastIO in = new FastIO(), out = in;
    int n = in.nextInt();
    int cur = 1, prev = 1, ans = 0;
    while(cur < n) {
      int tmp = cur;
      cur = prev+cur;
      prev = tmp;
      ans++;
    }
    out.println(ans);
    out.close();
  }

  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in, System.out);
    }

    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }

    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }

    public int numTokens() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }

    public String next() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}

import java.io.*;
import java.util.*;

public class Program implements Runnable {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(new Program());
        thread.start();
        thread.join();
    }

    final Scanner in = new Scanner(System.in);
    final PrintWriter out = new PrintWriter(System.out);

    public void run() {
        out.println(solve());
        out.flush();
    }

    int gcd(int a, int b) {
        if (a > b) {
            return gcd(b, a);
        }
        if (a == 0) {
            return b;
        }
        return gcd(b, b % a);
    }

    int solve() {
        int k = in.nextInt();
        int log = 0;
        while (k > 1) {
            log++;
            if (k % 2 == 1) {
                k++;
            }
            k /= 2;
        }
        return log;
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_Testing_Round_3 {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();

        out.println(fast(n));
        out.close();
    }
//
//    public static int cal(int a, int b, int n) {
//        LinkedList<Point> q = new LinkedList();
//        q.add(new Point(a, b));
//        HashMap<Point, Integer> map = new HashMap();
//        map.put(new Point(a, b), 0);
//        int result = n;
//        while (!q.isEmpty()) {
//
//            Point p = q.poll();
//            if (p.x == n || p.y == n) {
//                result = Math.min(result, map.get(p));
//            }
//            //  System.out.println(result + " " + map);
//            if (result <= map.get(p)) {
//                break;
//            }
//            if ((n - p.y) % p.x == 0) {
//                result = Math.min(result, (n - p.y) / p.x + map.get(p));
//            }
//            //  System.out.println(result + " " + map);
//            if ((n - p.x) % p.y == 0) {
//                result = Math.min(result, (n - p.x) / p.y + map.get(p));
//            }
//            //  System.out.println(result + " " + map);
//            map.put(new Point(p.x, p.x + p.y), map.get(p) + 1);
//            q.add(new Point(p.x, p.x + p.y));
//            map.put(new Point(p.y, p.x + p.y), map.get(p) + 1);
//            q.add(new Point(p.y, p.x + p.y));
//        }
//        return result;
//
//    }

    public static int fast(int n) {
        int result = n;
        for (int i = 1; i < n; i++) {

            int s = step(i, n);
            if (s != -1) {
                result = Math.min(result, s);
            }
        }
        return result;
    }

    public static int step(int a, int b) {
        if (a == 1) {
            return b - a;
        }
        if (a == 0) {
            return -1;
        }
        int need = b / a;
        int v = step(b % a, a);
        if (v != -1) {
            return need + v;
        }
        return -1;
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		StreamInputReader in = new StreamInputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, StreamInputReader in, OutputWriter out) {
        int n = in.readInt();
        int res = n-1;
        for(int i = 1; i < n; ++i) {
            res = Math.min(res, solve(i, n));
        }
        out.printLine(res);
	}
    private int solve(int a,int b) {
        int steps = 0;
        while (a >= 1 && b >= 1 && a != b) {
            if (a < b) b -= a;
            else a -=b;
            ++steps;
        }
        if (a == 1 && b == 1) {
            return steps;
        }
        return a+b;
    }
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    }

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(outputStream);
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}
}

abstract class InputReader {

	public abstract int read();

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    protected boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TestingRound3_B {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        int res = 10000000;
        for (int i = 1; i < n; i++) {
            int a = i;
            int b = n;
            int curr = 0;
            while(a>1 || b>1){
               if(a==b)
                   break;
               if(a==0 || b==0)
                   break;
               if(a>b){
                   a = a-b;
               }else
                   b = b-a;
               curr++;
            //   System.out.println(a+" "+b+" "+i+" "+curr);
            }
            if(a==1 && b==1)
            res = Math.min(res, curr);
        }
        System.out.println(res);
    }
}

import java.util.Scanner;

public class PairsofNumbers {

    public static int get(int a, int b)
    {
        int cnt = 0;
        while(true)
        {
            if(a == 1 && b == 1)
                return cnt;
            if(a < 1 || b < 1)
                return -1;

            if(a < b)
                b = b-a;
            else
                a = a-b;
            cnt++;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), limit = (N+1)/2;

        int min = Integer.MAX_VALUE;
        for(int i = 1; i <= limit; i++)
            min = Math.min(min, get(i, N));

        System.out.println(min);
    }
}

/*
 * Author Ayub Subhaniya
 * Institute DA-IICT
 */

import java.io.*;
import java.math.*;
import java.util.*;

public class Driver {

	InputStream in;
	PrintWriter out;

	void solve() {
		int n=ni();
		if (n==1)
		{
			out.println(0);
			return;
		}

		int steps=0;
		int f0=1,f1=1;
		while (f1<n)
		{
			f1=f1+f0;
			f0=f1-f0;
			steps++;
		}
		out.println(steps);
	}

	class Pair implements Comparable<Pair> {
		int x;
		int y;
		int i;
		Pair(int a, int b,int c) {
			x = a;
			y = b;
			i=c;
		}

		@Override
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return x == other.x && y == other.y;
		}

		public String toString() {
			return x + " " + y;
		}

		@Override
		public int compareTo(Pair o) {
			if (x == o.x)
				return Integer.compare(y, o.y);
			else
				return Integer.compare(x, o.x);
		}

		@Override
		public int hashCode() {
			return Objects.hash(x, y);
		}
	}

	void run() throws Exception {
		String INPUT = "C:/Users/ayubs/Desktop/input.txt";
		in = oj ? System.in : new FileInputStream(INPUT);
		out = new PrintWriter(System.out);

			long s = System.currentTimeMillis();
			solve();
			out.flush();
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Driver().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean inSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && inSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(inSpaceChar(b))) { // when nextLine, (inSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(inSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

/**
 *
 * @author zulkan
 */
public class numberOfPair {
    public static void main(String p[]) throws Exception{
        List<Long> temp;
        long arr[]=null;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int total=Integer.parseInt(br.readLine());
        arr=new long[2+46];
        arr[0]=1;
        arr[1]=1;

        //long sum=1;
        int a=2;
        int index=0;
        for(;a<48;a++){
            arr[a]=arr[a-1]+arr[a-2];
            //sum+=arr[a];
            if(arr[a]>=total){
                index=a;
            break;
        }
        }
        //System.out.println(arr[index]);
        for(int i=0;i<=index;i++){
            //System.out.println(arr[i]);
        }
        if(total==1){
            System.out.println("0");
            return;
        }
        if(index-1<0)index=0;
        else index-=1;
        System.out.println(index);

    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

/**
 *
 * @author zulkan
 */
public class numberOfPair {
    public static void main(String p[]) throws Exception{
        List<Long> temp;
        long arr[]=null;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int total=Integer.parseInt(br.readLine());
        arr=new long[2+46];
        arr[0]=1;
        arr[1]=1;

        //long sum=1;
        int a=2;
        int index=0;
        for(;a<48;a++){
            arr[a]=arr[a-1]+arr[a-2];
            //sum+=arr[a];
            if(arr[a]>=total){
                index=a;
            break;
        }
        }
        //System.out.println(arr[index]);
        for(int i=0;i<=index;i++){
            //System.out.println(arr[i]);
        }
        if(index-1<0)index=0;
        else index-=1;
        System.out.println(index);

    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author zulkan
 */
public class numberOfPair {
    public static void main(String p[]) throws Exception{
        List<Long> temp;
        long arr[]=null;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int total=Integer.parseInt(br.readLine());
        arr=new long[2+46];
        arr[0]=0;
        arr[1]=1;

        long sum=1;
        int a=2;
        int index=0;
        for(;a<48;a++){
            arr[a]=arr[a-1]+arr[a-2];
            sum+=arr[a];
            if(arr[a]<=total)index=a;
            /*
            long before=arr.get(arr.size()-1);
            long before_2=arr.get(arr.size()-2);
            arr.add(before+before_2);

             *
             */
        }
        if(index-2<0)index=0;
        else index-=2;
        System.out.println(index);
        temp=new ArrayList<Long>();
        temp.add(arr[index]);
        if(total-arr[index]>0)temp.add(total-arr[index]);
        //System.out.println(temp);
       if(temp.size()==2){
           pecah(temp.get(1));
       }else if (temp.size()==1){
           pecah(temp.get(0));
       }
    }
    static void pecah(long x){
        //temp.add();
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=Integer.MAX_VALUE;
        for (int i = 1; i <= input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            //print(step);
            if(step!=0){
                //print(step);
                out=Math.min(out,step);
            }
        }
        print (out-1);
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=99999;
        for (int i = 1; i < input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;

            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            if(b==1){
                out=Math.min(out,step);
            }
        }
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=Integer.MAX_VALUE;
        for (int i = 1; i <= input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            //print(step);
            //if(b==1){
                //print(step);
                out=Math.min(out,step);
            //}
        }
        print (out-1);
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=Integer.MAX_VALUE;
        if(input < 2){
            print(1);
            return;
        }
        for (int i = 1; i <= input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            //print(step);
            if(step!=1){
                //print(step);
                out=Math.min(out,step);
            }
        }
        print (out-1);
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;

public class pon {

    static BufferedReader br;

    public static void init() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public static String getString() {
        try {
            if (br == null) {
                init();
            }
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            if (br == null) {
                init();
            }
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            if (br == null) {
                init();
            }
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void main(String[] ar) {
     int init[]={1,1};
     int c=0;
     int inp=getInt();

     while(true){

         int max=Math.max(init[0], init[1]);
         int min=Math.min(init[0], init[1]);
         if(max>=inp){
             break;
         }
         c++;
         init[0]=max+min;
         init[1]=max;
     }
     System.out.println(c);
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

/**
 *
 * @author zulkan
 */
public class numberOfPair {
    public static void main(String p[]) throws Exception{
        List<Long> temp;
        long arr[]=null;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int total=Integer.parseInt(br.readLine());
        arr=new long[2+46];
        arr[0]=1;
        arr[1]=1;

        //long sum=1;
        int a=2;
        int index=0;
        for(;a<48;a++){
            arr[a]=arr[a-1]+arr[a-2];
            //sum+=arr[a];
            if(arr[a]>=total){
                index=a;
            break;
        }
        }
        //System.out.println(arr[index]);
        for(int i=0;i<=index;i++){
            System.out.println(arr[i]);
        }
        if(total==1){
            System.out.println("0");
            return;
        }
        if(index-1<0)index=0;
        else index-=1;
        System.out.println(index);

    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=99999;
        for (int i = 1; i < input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            if(b==1){
                out=Math.min(out,step);
            }
        }
        print (out-1);
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=Integer.MAX_VALUE;
        if(input < 2){
            print(0);
            return;
        }
        for (int i = 1; i <= input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            //print(step);
            if(step!=1){
                //print(step);
                out=Math.min(out,step);
            }
        }
        print (out-1);
    }
}

import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;

public class pon {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void printList(List<Integer> a) {
        System.out.println(a.toString().replace("[", "").replace("]", "").replace(",", ""));
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        String out = "";
        int temp = a;
        while (temp > 0) {
            out = temp % base + out;
            temp /= base;
        }
        return out;
    }

    public static void main(String[] ar) {
        int input = getInt();
        int out=Integer.MAX_VALUE;
        for (int i = 1; i <= input; i++) {
            int a = input;
            int b = i;
            int c = a % b;
            int step = a / b;
            while (c > 0) {
                a = b;
                b = c;
                c= a%b;
                step += a / b;
            }
            //print(step);
            if(step!=1){
                //print(step);
                out=Math.min(out,step);
            }
        }
        print (out-1);
    }
}

import java.io.*;
import java.lang.Math;
import java.util.*;

public class Main
{
	public BufferedReader in;
	public PrintStream out;

	public int calc(int a, int b)
	{
		if (a<b)
		{
			return calc(b,a);
		}

		if (b==0)
		{
			return -1;
		}

		if (b==1)
		{
			return a-b;
		}

		return  calc(b, a% b) + a/b;
	}

	public void test()
	{
		int n = readInt();
		int min = n-1;
		int c;

		for (int k=2; k<n; k++)
		{
			c = calc(n,k);
			if ((c>=0)&&(c<min))
			{
				min = c;
			}
		}

		out.println(min);
	}

	public void run()
	{
		try
		{
			in = new BufferedReader(new InputStreamReader(System.in));
			out = System.out;

			//in = new BufferedReader(new FileReader("in.txt"));
			//out = new PrintStream(new File("out.txt"));

		}
		catch (Exception e)
		{
			return;
		}

		//while (true)
		{
			//int t = readInt(); for (int i=0; i<t; i++)
			{
				test();
			}
		}
	}

	public static void main(String args[])
	{
		new Main().run();
	}

	private StringTokenizer tokenizer = null;

	public int readInt()
	{
        return Integer.parseInt(readToken());
    }

    public long readLong()
	{
        return Long.parseLong(readToken());
    }

    public double readDouble()
	{
        return Double.parseDouble(readToken());
    }

	public String readLn()
	{
		try
		{
			String s;
			while ((s = in.readLine()).length()==0);
			return s;
		}
		catch (Exception e)
		{
			return "";
		}
	}

    public String readToken()
	{
		try
		{
			while (tokenizer == null || !tokenizer.hasMoreTokens())
			{
				tokenizer = new StringTokenizer(in.readLine());
			}
			return tokenizer.nextToken();
		}
		catch (Exception e)
		{
			return "";
		}
    }

	public int[] readIntArray(int n)
	{
		int[] x = new int[n];
		readIntArray(x, n);
		return x;
	}

	public void readIntArray(int[] x, int n)
	{
		for (int i=0; i<n; i++)
		{
			x[i] = readInt();
		}
	}
}

import java.io.IOException;
import java.util.Scanner;

public class PairsofNumbers {
    static int k = 0;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println(0);
        } else {
            int step = 99999999;
            n -= 1;
            for (int i = n; n <= i * 2; i--) {
                step = Math.min(step, gcd(i, n - i));
            }
            System.out.println(step + 1);
        }
    }

    static int gcd(int a, int b) {
        if (a == 1 && b == 1)
            return 0;
        if (b == 1)
            return a - 1;
        if (b == 0)
            return 99999999;
        return gcd(b, a % b) + a / b;
    }
}

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PairsofNumbers {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int k = bf.read() - '0';
        Point p1 = new Point(1, 1);
        Point p2 = new Point(1, 1);
        int n = 0;
        while (true) {
            if (p1.x == k || p1.y == k || p2.x == k || p2.y == k) {
                System.out.println(Math.max(0, n - 1));
                break;
            } else {
                p1.move(p1.x + p1.y, p1.y);
                p2.move(p2.x, p2.y + p2.x);
                ++n;
            }
        }
    }
}

import java.io.IOException;
import java.util.Scanner;

public class PairsofNumbers {
    static int k = 0;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println(0);
        } else {
            int step = 99999999;
            n -= 1;
            for (int i = n; n <= i * 2; i--) {
                step = Math.min(step, gcd(i, n - i));
            }
            System.out.println(step == 99999999 ? 1 : ++step);
        }
    }

    static int gcd(int a, int b) {
        if (a == 1 && b == 1)
            return 0;
        if (b == 1)
            return a - 1;
        if (b == 0)
            return 99999999;
        return gcd(b, a % b) + a / b;
    }
}

import java.io.IOException;
import java.util.Scanner;

public class PairsofNumbers {
    static int k = 0;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println(0);
        } else {
            int step = 99999999;
            n -= 1;
            for (int i = n; n <= i * 2; i--) {
                step = Math.min(step, gcd(i, n - i));
            }
            System.out.println(step == 99999999 ? 1 : ++step);
        }
    }

    static int gcd(int a, int b) {
        if (a == 1 && b == 1)
            return 0;
        if (b == 1)
            return a - 1;
        if (b == 0)
            return 99999999;
        return a / b + gcd(b, a % b);
    }
}

import java.io.* ;
import java.util.*;

import static java.lang.Math.* ;
import static java.util.Arrays.* ;

public class B {

	public static void main(String[] args) throws IOException {

		new B().solveProblem();

		out.close();
	}

	static Scanner in = new Scanner(new InputStreamReader(System.in));
	//static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static PrintStream out = new PrintStream(new BufferedOutputStream(System.out));

	public void solveProblem() {

		int n = in.nextInt() ;

		int a = 1 ;
		int b = 1 ;

		int t = 0 ;
		while( a < n && b < n ){

			if( a < b )
				a += b ;
			else
				b += a ;
			t++ ;
		}

		out.println(t) ;
	}

}

/**
 * Created by IntelliJ IDEA.
 * User: jte
 * Date: 12/2/11
 * Time: 4:59 PM
 * To change this template use File | Settings | File Templates.
 */

import java.io.*;
import java.util.*;

public class TaskBV extends Thread {
    public TaskBV(int what) {
        try {
            if (what == 0) {
                this.input = new BufferedReader(new InputStreamReader(System.in));
                this.output = new PrintWriter(System.out);
            } else {
                this.input = new BufferedReader(new FileReader(INPUT_FILE));
                this.output = new PrintWriter(OUTPUT_FILE);
            }
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(666);
        }
    }
    private static final int go(int a, int b) {
        if (b == 0 && a == 1) {
            return -1;
        }

        return  b == 0 ? Integer.MAX_VALUE >> 3 : go( b, a % b) +  a / b;
    }

    private void solve() throws Throwable {
        int n = nextInt(), result = Integer.MAX_VALUE;
        for (int i = 1; i < n; ++i) {
            result = Math.min(result, go(n, i));
        }
        output.println(result);

    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String... args) {
        new TaskBV(0).start();
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private String INPUT_FILE = null;
    private String OUTPUT_FILE = null;
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}

import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int k = nextInt();

		int m[] = new int[100];
		m[0] = m[1] = 1;
		int i = 2;
		for(; i < 35; i++){
			m[i] = m[i - 1] + m[i - 2];
			if(k <= m[i]) break;
		}
		if(k == 1)
			i = 1;
		out.println(i - 1);

		in.close();
		out.close();
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}

import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int ans = Integer.MAX_VALUE;
		int k = nextInt();
		loop: for(int r = 1; r < k; r++){
			int a = k;
			int b = r;
			if(a % b == 0) continue;
			int c = 0;
			while(a + b > 2){
				if(a > b){b ^= a; a ^= b; b ^= a;}
				b = b - a;
				c++;
				if((a != 1 && a == b) || b == 0) continue loop;
			}
			ans = min(ans, c);
		}
		if(k == 1)
			out.println(0);
		else
			out.println(ans);

		in.close();
		out.close();
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}

import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int k = nextInt();

		int m[] = new int[100];
		m[0] = m[1] = 1;
		int i = 2;
		for(; i < 32; i++){
			m[i] = m[i - 1] + m[i - 2];
			if(k <= m[i]) break;
		}
		if(k == 1)
			i = 1;
		out.println(i - 1);

		in.close();
		out.close();
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}

import java.util.Scanner;

public class B134 {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int min = Integer.MAX_VALUE;
		if(n==1)
			min = 0;
		for(int a = 1;a<=n/2;a++) {
			int x = a,y = n-a;
			int c = 1;
			while(!(x==1&& y==1)) {
				int m = y%x;
				if(m==0) {
					c--;
					m++;
				}
				c+=y/x;
				y = x;
				x = m;
			}
			if(c<min) min = c;
		}

		System.out.println(min);
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

public class Main
{
    BufferedReader reader;
    FastScanner sc;

    int eulerPhi(int arg)
    {
        int result = arg;
        for (int i = 2; i * i <= arg; i++)
        {
            if (arg % i == 0)
            {
                while (arg % i == 0)
                {
                    arg /= i;
                }
                result -= result / i;
            }
        }
        if (arg > 1)
        {
            result -= result / arg;
        }
        return result;
    }

    void solve() throws Exception
    {
        int n = sc.nextInt();
        if (n == 1)
            System.out.println(0);
        else if (eulerPhi(n) == 2)
            System.out.println(n - 1);
        else
            System.out.println((n + 1) / 2);
    }

    public static void main(String[] args) throws Exception
    {
        new Main().solve();
    }

    Main() throws Exception
    {
        if (System.getProperty("ONLINE_JUDGE") == null)
        {
            //System.setIn(new FileInputStream("input.txt"));
            //System.setOut(new PrintStream("output.txt"));
        }

        reader = new BufferedReader(new InputStreamReader(System.in));
        sc = new FastScanner(reader);
    }
}

class FastScanner
{
    BufferedReader reader;
    StringTokenizer strTok;

    public FastScanner(BufferedReader reader)
    {
        this.reader = reader;
    }

    public String nextToken() throws IOException
    {
        if (strTok == null || !strTok.hasMoreTokens())
        {
            strTok = new StringTokenizer(reader.readLine());
        }
        return strTok.nextToken();
    }

    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException
    {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextToken());
    }

    public BigInteger nextBigInteger() throws IOException
    {
        return new BigInteger(nextToken());
    }

    public BigDecimal nextBigDecimal() throws IOException
    {
        return new BigDecimal(nextToken());
    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class TaskB {
	void Run() throws IOException {
		int n=ReadInt();
		if(n==1) {
			output.print(1);
			return;
		}
		int res=Integer.MAX_VALUE;
		for(int i=1;i<=n/2;++i) {
			int[] b=Gcd(i, n-i);
			if(b[0]==1)
				res=Math.min(res, b[1]);
		}
		output.print(res);
	}

	static int[] Gcd(int a, int b) {
		if(a==0)
			return new int[]{b, 0};
		int[] res=Gcd(b%a, a);
		res[1]+=b/a;
		return res;
	}

	public static void main(String[] args) throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		Reader reader;
		reader=oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
		input=new BufferedReader(reader);
		Writer writer=new OutputStreamWriter(System.out);
		writer=new BufferedWriter(writer);
		output=new PrintWriter(writer);
		new TaskB().Run();
		output.close();
	}

	static int ReadInt() throws IOException {
		return Integer.parseInt(ReadString());
	}

	static long ReadLong() throws IOException {
		return Long.parseLong(ReadString());
	}

	static String ReadString() throws IOException {
		while(tokenizer==null || !tokenizer.hasMoreTokens())
			tokenizer=new StringTokenizer(input.readLine());
		return tokenizer.nextToken();
	}

	static StringTokenizer tokenizer;
	static BufferedReader input;
	static PrintWriter output;
}

import static java.lang.Math.*;
import java.util.*;
import java.io.*;

public class B {

    public void solve() throws Exception {

        int n = nextInt();
        int k = n-1;
        for (int i=2; i<n; ++i) if (gcd(n,i)==1) {
            int a = n, b = i;
            int r = 1;
            while (b!=1 || a!=1) {
                r++;
                if (a>b) a-=b;
                else b-=a;
            }
            k = min(k,r);
        }
        println(k);

    }

    int gcd (int a, int b) {
        while (b>0) {
            a%=b;
            a^=b; b^=a; a^=b;
        }
        return a;
    }

    ////////////////////////////////////////////////////////////////////////////

    boolean showDebug = true;
    static boolean useFiles = false;
    static String inFile = "input.txt";
    static String outFile = "output.txt";

    double EPS = 1e-7;
    int INF = Integer.MAX_VALUE;
    long INFL = Long.MAX_VALUE;
    double INFD = Double.MAX_VALUE;

    int absPos(int num) {
        return num<0 ? 0:num;
    }
    long absPos(long num) {
        return num<0 ? 0:num;
    }
    double absPos(double num) {
        return num<0 ? 0:num;
    }

    int min(int... nums) {
        int r = INF;
        for (int i: nums)
            if (i<r) r=i;
        return r;
    }
    int max(int... nums) {
        int r = -INF;
        for (int i: nums)
            if (i>r) r=i;
        return r;
    }
    long minL(long... nums) {
        long r = INFL;
        for (long i: nums)
            if (i<r) r=i;
        return r;
    }
    long maxL(long... nums) {
        long r = -INFL;
        for (long i: nums)
            if (i>r) r=i;
        return r;
    }
    double minD(double... nums) {
        double r = INFD;
        for (double i: nums)
            if (i<r) r=i;
        return r;
    }
    double maxD(double... nums) {
        double r = -INFD;
        for (double i: nums)
            if (i>r) r=i;
        return r;
    }

    long sumArr(int[] arr) {
        long res = 0;
        for (int i: arr)
            res+=i;
        return res;
    }
    long sumArr(long[] arr) {
        long res = 0;
        for (long i: arr)
            res+=i;
        return res;
    }
    double sumArr(double[] arr) {
        double res = 0;
        for (double i: arr)
            res+=i;
        return res;
    }

    long partsFitCnt(long partSize, long wholeSize) {
        return (partSize+wholeSize-1)/partSize;
    }

    boolean odd(long num) {
        return (num&1)==1;
    }

    boolean hasBit(int num, int pos) {
        return (num&(1<<pos))>0;
    }

    long binpow(long a, int n) {
        long r = 1;
        while (n>0) {
            if ((n&1)!=0) r*=a;
            a*=a;
            n>>=1;
        }
        return r;
    }

    boolean isLetter(char c) {
        return (c>='a' && c<='z') || (c>='A' && c<='Z');
    }
    boolean isLowercase(char c) {
        return (c>='a' && c<='z');
    }
    boolean isUppercase(char c) {
        return (c>='A' && c<='Z');
    }
    boolean isDigit(char c) {
        return (c>='0' && c<='9');
    }

    String stringn(String s, int n) {
        if (n<1) return "";
        StringBuilder sb = new StringBuilder(s.length()*n);
        for (int i=0; i<n; ++i) sb.append(s);
        return sb.toString();
    }
    String str(Object o) {
        return o.toString();
    }

    long timer = System.currentTimeMillis();
    void startTimer() {
        timer = System.currentTimeMillis();
    }
    void stopTimer() {
        System.err.println("time: "+(System.currentTimeMillis()-timer)/1000.0);
    }

    static class InputReader {
        private byte[] buf;
        private int bufPos = 0, bufLim = -1;
        private InputStream stream;
        public InputReader(InputStream stream, int size) {
            buf = new byte[size];
            this.stream = stream;
        }
        private void fillBuf() throws IOException {
            bufLim = stream.read(buf);
            bufPos = 0;
        }
        char read() throws IOException {
            if (bufPos>=bufLim) fillBuf();
            return (char)buf[bufPos++];
        }
        boolean hasInput() throws IOException {
            if (bufPos>=bufLim) fillBuf();
            return bufPos<bufLim;
        }
    }

    static InputReader inputReader;
    static BufferedWriter outputWriter;

    char nextChar() throws IOException {
        return inputReader.read();
    }
    char nextNonWhitespaceChar() throws IOException {
        char c = inputReader.read();
        while (c<=' ') c=inputReader.read();
        return c;
    }
    String nextWord() throws IOException {
        StringBuilder sb = new StringBuilder();
        char c = inputReader.read();
        while (c<=' ') c=inputReader.read();
        while (c>' ') {
            sb.append(c);
            c = inputReader.read();
        }
        return new String(sb);
    }
    String nextLine() throws IOException {
        StringBuilder sb = new StringBuilder();
        char c = inputReader.read();
        while (c<=' ') c=inputReader.read();
        while (c!='\n' && c!='\r') {
            sb.append(c);
            c = inputReader.read();
        }
        return new String(sb);
    }
    int nextInt() throws IOException {
        int r = 0;
        char c = nextNonWhitespaceChar();
        boolean neg = false;
        if (c=='-') neg=true;
        else r=c-48;
        c = nextChar();
        while (c>='0' && c<='9') {
            r*=10;
            r+=c-48;
            c=nextChar();
        }
        return neg ? -r:r;
    }
    long nextLong() throws IOException {
        long r = 0;
        char c = nextNonWhitespaceChar();
        boolean neg = false;
        if (c=='-') neg=true;
        else r = c-48;
        c = nextChar();
        while (c>='0' && c<='9') {
            r*=10L;
            r+=c-48L;
            c=nextChar();
        }
        return neg ? -r:r;
    }
    double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextWord());
    }
    int[] nextArr(int size) throws NumberFormatException, IOException {
        int[] arr = new int[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextInt();
        return arr;
    }
    long[] nextArrL(int size) throws NumberFormatException, IOException {
        long[] arr = new long[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextLong();
        return arr;
    }
    double[] nextArrD(int size) throws NumberFormatException, IOException {
        double[] arr = new double[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextDouble();
        return arr;
    }
    String[] nextArrS(int size) throws NumberFormatException, IOException {
        String[] arr = new String[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextWord();
        return arr;
    }
    char[] nextArrCh(int size) throws IOException {
        char[] arr = new char[size];
        for (int i=0; i<size; ++i)
            arr[i] = nextNonWhitespaceChar();
        return arr;
    }
    char[][] nextArrCh(int rows, int columns) throws IOException {
        char[][] arr = new char[rows][columns];
        for (int i=0; i<rows; ++i)
            for (int j=0; j<columns; ++j)
                arr[i][j] = nextNonWhitespaceChar();
        return arr;
    }
    char[][] nextArrChBorders(int rows, int columns, char border) throws IOException {
        char[][] arr = new char[rows+2][columns+2];
        for (int i=1; i<=rows; ++i)
            for (int j=1; j<=columns; ++j)
                arr[i][j] = nextNonWhitespaceChar();
        for (int i=0; i<columns+2; ++i) {
            arr[0][i] = border;
            arr[rows+1][i] = border;
        }
        for (int i=0; i<rows+2; ++i) {
            arr[i][0] = border;
            arr[i][columns+1] = border;
        }
        return arr;
    }

    void printf(String format, Object... args) throws IOException {
        outputWriter.write(String.format(format, args));
    }
    void print(Object o) throws IOException {
        outputWriter.write(o.toString());
    }
    void println(Object o) throws IOException {
        outputWriter.write(o.toString());
        outputWriter.newLine();
    }
    void print(Object... o) throws IOException {
        for (int i=0; i<o.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(o[i].toString());
        }
    }
    void println(Object... o) throws IOException {
        print(o);
        outputWriter.newLine();
    }
    void printn(Object o, int n) throws IOException {
        String s = o.toString();
        for (int i=0; i<n; ++i) {
            outputWriter.write(s);
            if (i!=n-1) outputWriter.write(' ');
        }
    }
    void printnln(Object o, int n) throws IOException {
        printn(o, n);
        outputWriter.newLine();
    }
    void printArr(int[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(Integer.toString(arr[i]));
        }
    }
    void printArr(long[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(Long.toString(arr[i]));
        }
    }
    void printArr(double[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(Double.toString(arr[i]));
        }
    }
    void printArr(String[] arr) throws IOException {
        for (int i=0; i<arr.length; ++i) {
            if (i!=0) outputWriter.write(' ');
            outputWriter.write(arr[i]);
        }
    }
    void printArr(char[] arr) throws IOException {
        for (char c: arr) outputWriter.write(c);
    }
    void printlnArr(int[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(long[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(double[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(String[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void printlnArr(char[] arr) throws IOException {
        printArr(arr);
        outputWriter.newLine();
    }
    void halt(Object... o) throws IOException {
        if (o.length!=0) println(o);
        outputWriter.flush(); outputWriter.close();
        System.exit(0);
    }

    void debug(Object... o) {
        if (showDebug) System.err.println(Arrays.deepToString(o));
    }

    public static void main(String[] args) throws Exception {
        Locale.setDefault(Locale.US);
        if (!useFiles) {
            inputReader = new InputReader(System.in, 1<<16);
            outputWriter = new BufferedWriter(new OutputStreamWriter(System.out), 1<<16);
        } else {
            inputReader = new InputReader(new FileInputStream(new File(inFile)), 1<<16);
            outputWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outFile))), 1<<16);
        }
        new B().solve();
        outputWriter.flush(); outputWriter.close();
    }
}

import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	private void start() {
		Scanner in = new Scanner(System.in);

		int n;

		n = in.nextInt();

		if (n == 1) {
			System.out.println(0);
			return;
		}
		int k = Integer.MAX_VALUE;
		for (int i = 1; i < n; i++) {
			k = Math.min(k, calc(i, n));
		}
		System.out.println(k);
	}

	private int calc(int i, int n) {

		if (i == 1) {
			return n - 1;
		}

		int ret = 0;

		while (true) {
			if (i > n) {
				int t = i;
				i = n;
				n = t;
			}

			if (n % i == 0) {
				return Integer.MAX_VALUE;
			}

			if (i == 1) {
				ret += n - 1;
				break;
			}
			int q = n / i;
			ret += q;
			n = n - i * q;

			if (i == 1 && n == 1) {
				break;
			}
		}
		return ret;
	}

	public static void main(String[] args) {
		new Main().start();
	}
}

//package test3;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int[] f = new int[30];
		f[0] = f[1] = 1;
		for(int i = 2;i < 30;i++){
			f[i] = f[i-1] + f[i-2];
		}
		int n = ni();
		int ct = 9999999;
		for(int i = 0;i < 28;i++){
			if((n-f[i+1]) % f[i] == 0){
				ct = Math.min(ct, i + (n-f[i+1])/f[i]);
			}
		}
		out.println(ct);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new B().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

/**
 * @author Juan Sebastian Beltran Rojas
 * @mail jsbeltran.valhalla@gmail.com
 * @veredict No enviado
 * @problemId 134B
 * @problemName Pairs of Numbers
 * @judge http://www.codeforces.com/
 * @category math
 * @level easy
 * @date 01/08/2012
 **/
import java.io.*;
import static java.lang.Integer.*;
import static java.lang.Math.*;
public class CF134B{
	static int f(int a,int b){
		int c;
		if(a==1||b==1)return max(a,b)-1;
		if(a>b&&a%b!=0&&(c=f(a%b,b))!=MAX_VALUE)return c+a/b;
		if(b>a&&b%a!=0&&(c=f(a,b%a))!=MAX_VALUE)return c+b/a;
		return MAX_VALUE;
	}
	public static void main(String args[]) throws Throwable{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		int n=parseInt(in.readLine()),r=MAX_VALUE;
		for(int i=1;i<n;i++)r=min(r,f(n,i));
		System.out.println(r);
	}
}

import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;

public class b3 {
    public static void debug(Object... obs) {
        System.out.println(Arrays.deepToString(obs));
    }

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n=sc.nextInt();

        int ming=n-1;
        for(int i=2;i<n;i++)
        {
            if(n%i==0) continue;
            int a=Math.max(n,i);
            int b=Math.min(n,i);
            int cnt=0;
            while(b > 1)
            {
                int tmp1=Math.min(a,b);
                int tmp2=Math.max(a,b);

                a = Math.max(tmp1,tmp2 - tmp1);
                b = Math.min(tmp1,tmp2 - tmp1);
                cnt++;
            }
            cnt+=a-1;

            //debug(n,i,cnt);
            ming=Math.min(ming, cnt);
        }
        System.out.println(ming);
    }
}