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

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

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;
	long[] a;

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

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

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

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

	public long get(long n) {
		if (n <= 0)
			return 0;
		long res = 0;
		long pz = 0;
		long z = 1;
		int i = 0;
		while (n >= z) {
			n -= z;
			res += a[i];
			long t = z;
			z += pz;
			pz = t;
			i++;
			
		}
		return res + get(n - 1);
	}

	public void solve() throws IOException {
		long n = nextInt();
		assert((1 <= n) && (n <= (long)5000));
		if (n <= 2) {
			out.println("0");
			return;
		}

		long c = 1;
		long d = 1;
		a = new long[10000];
		a[0] = 1;
		a[1] = 0;
		long sum = 3;
		long count = 2;
		for (int i = 2; sum < n; i++) {
			a[i] = a[i - 1] + a[i - 2];
			long tmp = sum;
			sum += (c + d) * (i + 1);
			if (sum < n)
				count += (c + d);
			else
				count += (n - tmp - 1) / (i + 1);
			long t = d;
			d += c;
			c = t;
		}
		out.println(get(count));
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			br = new BufferedReader(new FileReader("fibseq.in"));
			out = new PrintWriter("fibseq.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}