import java.util.HashMap;
import java.util.Map;

public class Euler384 {
    static class CacheKey {
        long t, x;

        CacheKey(long t, long x) {
            this.t = t;
            this.x = x;
        }

        @Override
        public int hashCode() {
            int h1 = Long.hashCode(t);
            int h2 = Long.hashCode(x);
            return h1 ^ (h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2));
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof CacheKey))
                return false;
            CacheKey other = (CacheKey) o;
            return this.t == other.t && this.x == other.x;
        }
    }

    static class CountPair {
        long pos, neg;

        CountPair(long p, long n) {
            this.pos = p;
            this.neg = n;
        }
    }

    static Map<CacheKey, CountPair> memo = new HashMap<>();

    static CountPair prefixCounts(long t, long x) {
        if (t == 0 || x < 0)
            return new CountPair(0, 0);
        if (t == 1)
            return new CountPair(1, 0);

        CacheKey key = new CacheKey(t, x);
        CountPair res = memo.get(key);
        if (res != null)
            return res;

        if ((t & 1) == 0) {
            long u = t / 2;
            long x1 = Math.floorDiv(x - 1, 4);
            long x3 = Math.floorDiv(x - 3, 4);
            CountPair a = prefixCounts(u, x1);
            CountPair b = prefixCounts(u, x3);
            if ((u & 1) == 0)
                res = new CountPair(a.pos + b.pos, a.neg + b.neg);
            else
                res = new CountPair(a.pos + b.neg, a.neg + b.pos);
        } else {
            long u = t / 2;
            long x0 = Math.floorDiv(x, 4);
            long x2 = Math.floorDiv(x - 2, 4);
            CountPair u0 = prefixCounts(u, x0);
            CountPair u2 = prefixCounts(u, x2);
            CountPair v0 = prefixCounts(u + 1, x0);
            CountPair v2 = prefixCounts(u + 1, x2);

            if ((u & 1) == 1)
                res = new CountPair(u2.pos + v0.pos, u0.neg + v2.pos);
            else
                res = new CountPair(u2.neg + v0.pos, u0.neg + v2.neg);
        }

        memo.put(key, res);
        return res;
    }

    static long countTotal(long t, long x) {
        CountPair p = prefixCounts(t, x);
        return p.pos + p.neg;
    }

    static long g(long t, long c) {
        if (t == 0 || c == 0 || c > t)
            return 0;
        long lo = 0;
        long hi = 1;
        while (countTotal(t, hi) < c) {
            hi *= 2;
        }
        while (lo < hi) {
            long mid = lo + (hi - lo) / 2;
            if (countTotal(t, mid) >= c)
                hi = mid;
            else
                lo = mid + 1;
        }
        return lo;
    }

    static String solve() {
        memo.clear();
        long[] fib = new long[46];
        fib[0] = 1;
        fib[1] = 1;
        for (int i = 2; i <= 45; i++) {
            fib[i] = fib[i - 1] + fib[i - 2];
        }

        long sum = 0;
        for (int t = 2; t <= 45; t++) {
            sum += g(fib[t], fib[t - 1]);
        }
        return Long.toString(sum);
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
