import static java.util.Arrays.deepToString;

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

public class fibseq_nn {

	static final long[] F;
	static final long MAXN = 1000000000L * 1000000000L;
	static {
		List<Long> f = new ArrayList<Long>();
		f.add(1L);
		f.add(2L);
		while (true) {
			long next = f.get(f.size() - 1) + f.get(f.size() - 2);
			if (next > MAXN) {
				break;
			}
			f.add(next);
		}
		F = new long[f.size()];
		for (int i = 0; i < F.length; i++) {
			F[i] = f.get(i);
		}
	}

	static void solve() throws Exception {
		long n = nextLong();
		assert 1 <= n && n <= MAXN;
		out.println(solve(n));
	}

	static long solve(long n) {
		if (n == 1) {
			return 0;
		}
		long answer = 1;
		for (int i = 1; i <= F.length; i++) {
			if (n > getFibonacci(i) * i) {
				n -= getFibonacci(i) * i;
				answer += getFibonacci(i - 2);
			} else {
				if (n == 0) {
					break;
				}
				long count = (n - 1) / i;
				for (int j = i - 2; j > 0; j--) {
					long f = F[j];
					if (count >= f) {
						count -= f;
						answer += getFibonacci(j);
					}
				}
				break;
			}
		}
		return answer;
	}

	static long getFibonacci(int n) {
		return n <= 0 ? 0 : n == 1 ? 1 : F[n - 2];
	}

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

	static void debug(Object... a) {
		System.err.println(deepToString(a));
	}

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

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

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

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

	public static void main(String[] args) {
		try {
			File file = new File("fibseq.in");
			InputStream input = System.in;
			OutputStream output = System.out;
			if (file.canRead()) {
				input = (new FileInputStream(file));
				output = (new PrintStream("fibseq.out"));
			}
			br = new BufferedReader(new InputStreamReader(input));
			out = new PrintWriter(output);
			solve();
			out.close();
			br.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}