import static java.util.Arrays.deepToString;

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

public class calendar_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);
		}
		getDP();
	}

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

	static long solve(long n) {
		--n;
		long answer = 0;
		for (int len = 2; n > 0 && len < F.length; len++) {
			long countThatLen = F[len - 2];
			if (countThatLen * len > n) {
				long newN = F[len - 1] + n / len;
				answer += getForConstLen(len, newN, dp);
				answer += getForNumber(newN, (int) (n % len));
				n = 0;
			} else {
				n -= countThatLen * len;
				answer += dp[1][len];
			}
		}
		return answer;
	}

	static int getForNumber(long n, int len) {
		String f = toFibonacci(n);
		f = f.substring(0, len);
		int ret = 0;
		for (int i = 0; i < f.length() - 1; i++) {
			if (f.charAt(i) == '0' && f.charAt(i + 1) == '0') {
				ret++;
			}
		}
		return ret;
	}

	static String toFibonacci(long n) {
		int i = 0;
		while (i + 1 < F.length && F[i + 1] <= n) {
			i++;
		}
		StringBuilder ret = new StringBuilder();
		while (i >= 0) {
			if (n >= F[i]) {
				n -= F[i];
				ret.append('1');
			} else {
				ret.append('0');
			}
			i--;
		}
		return ret.toString();
	}

	static long getForConstLen(int len, long n, long[][] dp) {
		int[] number = new int[len];
		{
			long m = n;
			for (int i = len - 1; i >= 0; i--) {
				if (m >= F[i]) {
					number[i] = 1;
					m -= F[i];
				}
			}
		}
		int zeros = 0;
		long ret = 0;
		for (int i = len - 2; i >= 0; i--) {
			if (number[i] == 1) {
				ret += dp[0][i + 1] + zeros * count[0][i + 1];
				if (number[i + 1] == 0) {
					ret += count[0][i + 1];
				}
			}
			if (number[i] == 0 && number[i + 1] == 0) {
				zeros++;
			}
		}
		return ret;
	}

	static long[][] dp;
	static long[][] count;

	/**
	 * Computes dp[i][j] = number of appearances of "00" in all Fibonacci
	 * numbers of length j, which start with digit i. count[i][j] = number of
	 * Fibonacci numbers of length j, which start with digit i.
	 * 
	 * 
	 */
	static void getDP() {
		dp = new long[2][F.length];
		count = new long[2][F.length];
		count[0][1] = count[1][1] = 1;
		for (int len = 2; len < F.length; len++) {
			dp[0][len] = count[0][len - 1] + dp[0][len - 1] + dp[1][len - 1];
			dp[1][len] = dp[0][len - 1];
			count[0][len] = count[1][len - 1] + count[0][len - 1];
			count[1][len] = count[0][len - 1];
		}
	}

	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("calendar.in");
			InputStream input = System.in;
			OutputStream output = System.out;
			if (file.canRead()) {
				input = (new FileInputStream(file));
				output = (new PrintStream("calendar.out"));
			}
			br = new BufferedReader(new InputStreamReader(input));
			out = new PrintWriter(output);
			solve();
			out.close();
			br.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}