import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class Euler955 {

    static long mulModU64(long a, long b, long mod) {
        return BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)).mod(BigInteger.valueOf(mod)).longValue();
    }

    static long powModU64(long base, long exp, long mod) {
        long result = 1 % mod;
        long cur = base % mod;
        while (exp > 0) {
            if ((exp & 1L) != 0L) {
                result = mulModU64(result, cur, mod);
            }
            cur = mulModU64(cur, cur, mod);
            exp >>= 1L;
        }
        return result;
    }

    static boolean isPrimeU64(long n) {
        if (n < 2L) {
            return false;
        }
        long[] smallPrimes = { 2L, 3L, 5L, 7L, 11L, 13L, 17L, 19L, 23L, 29L, 31L, 37L };
        for (long p : smallPrimes) {
            if (n == p)
                return true;
            if (n % p == 0L)
                return false;
        }

        long d = n - 1L;
        int s = 0;
        while ((d & 1L) == 0L) {
            d >>= 1L;
            ++s;
        }

        long[] aValues = { 2L, 325L, 9375L, 28178L, 450775L, 9780504L, 1795265022L };
        for (long a : aValues) {
            if (a % n == 0L)
                continue;
            long x = powModU64(a % n, d, n);
            if (x == 1L || x == n - 1L)
                continue;
            boolean witness = true;
            for (int r = 1; r < s; ++r) {
                x = mulModU64(x, x, n);
                if (x == n - 1L) {
                    witness = false;
                    break;
                }
            }
            if (witness)
                return false;
        }
        return true;
    }

    static long gcd(long a, long b) {
        while (b != 0) {
            long t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    static long nextLong(Random rng, long n) {
        long bits, val;
        do {
            bits = (rng.nextLong() << 1) >>> 1;
            val = bits % n;
        } while (bits - val + (n - 1) < 0L);
        return val;
    }

    static long pollardRho(long n, Random rng) {
        if ((n & 1L) == 0L)
            return 2L;
        if (n % 3L == 0L)
            return 3L;

        while (true) {
            long c = nextLong(rng, n - 3) + 2;
            long x = nextLong(rng, n - 3) + 2;
            long y = x;
            long d = 1L;

            while (d == 1L) {
                x = (mulModU64(x, x, n) + c) % n;
                y = (mulModU64(y, y, n) + c) % n;
                y = (mulModU64(y, y, n) + c) % n;

                long diff = x > y ? x - y : y - x;
                d = gcd(diff, n);
            }
            if (d != n)
                return d;
        }
    }

    static void factorU64(long n, Map<Long, Integer> factors, Random rng) {
        if (n == 1L)
            return;
        if (isPrimeU64(n)) {
            factors.put(n, factors.getOrDefault(n, 0) + 1);
            return;
        }
        long d = pollardRho(n, rng);
        factorU64(d, factors, rng);
        factorU64(n / d, factors, rng);
    }

    static BigInteger isqrtU128(BigInteger x) {
        if (x.equals(BigInteger.ZERO))
            return BigInteger.ZERO;
        BigInteger s = new BigInteger(String.format("%.0f", Math.sqrt(x.doubleValue())));
        while (s.add(BigInteger.ONE).pow(2).compareTo(x) <= 0) {
            s = s.add(BigInteger.ONE);
        }
        while (s.pow(2).compareTo(x) > 0) {
            s = s.subtract(BigInteger.ONE);
        }
        return s;
    }

    static BigInteger triangleU128(BigInteger m) {
        return m.multiply(m.add(BigInteger.ONE)).divide(BigInteger.valueOf(2));
    }

    static class Pair {
        BigInteger first;
        BigInteger second;

        Pair(BigInteger first, BigInteger second) {
            this.first = first;
            this.second = second;
        }
    }

    static class Factor {
        long prime;
        int exp;

        Factor(long prime, int exp) {
            this.prime = prime;
            this.exp = exp;
        }
    }

    static Pair nextTriangleState(BigInteger m, Random rng) {
        long a = m.longValue();
        long b = m.add(BigInteger.ONE).longValue();

        Map<Long, Integer> fac = new HashMap<>();
        factorU64(a, fac, rng);
        factorU64(b, fac, rng);

        List<Factor> pf = new ArrayList<>();
        for (Map.Entry<Long, Integer> entry : fac.entrySet()) {
            pf.add(new Factor(entry.getKey(), entry.getValue()));
        }

        BigInteger p = m.multiply(m.add(BigInteger.ONE));
        BigInteger root = isqrtU128(p);

        BigInteger[] bestU = { BigInteger.ZERO };
        dfs(pf, 0, BigInteger.ONE, p, root, bestU);

        BigInteger v = p.divide(bestU[0]);
        BigInteger jump = v.subtract(bestU[0]).subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
        BigInteger nextM = bestU[0].add(v).subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
        return new Pair(jump, nextM);
    }

    static void dfs(List<Factor> pf, int idx, BigInteger cur, BigInteger p, BigInteger root, BigInteger[] bestU) {
        if (idx == pf.size()) {
            if (cur.compareTo(root) > 0)
                return;
            BigInteger v = p.divide(cur);
            if (cur.add(v).testBit(0) && v.compareTo(cur.add(BigInteger.ONE)) > 0 && cur.compareTo(bestU[0]) > 0) {
                bestU[0] = cur;
            }
            return;
        }

        Factor factor = pf.get(idx);
        BigInteger val = BigInteger.ONE;
        for (int e = 0; e <= factor.exp; ++e) {
            dfs(pf, idx + 1, cur.multiply(val), p, root, bestU);
            val = val.multiply(BigInteger.valueOf(factor.prime));
        }
    }

    static Pair solveKthTriangleHit(int k) {
        Random rng = new Random(0xC0FFEE);

        int hit = 1;
        BigInteger index = BigInteger.ZERO;
        BigInteger m = BigInteger.valueOf(2);

        while (hit < k) {
            Pair next = nextTriangleState(m, rng);
            index = index.add(next.first);
            m = next.second;
            ++hit;
        }

        return new Pair(index, m);
    }

    public static String solve() {
        return solveKthTriangleHit(70).first.toString();
    }

    public static void main(String[] args) {
        Pair res10 = solveKthTriangleHit(10);
        if (!res10.first.equals(BigInteger.valueOf(2964))
                || !triangleU128(res10.second).equals(BigInteger.valueOf(1439056))) {
            System.out.println("Validation failed");
            return;
        }
        System.out.println(solve());
    }
}
