import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;

public class Euler622 {
    static long modMul(long a, long b, long mod) {
        long res = 0;
        a %= mod;
        while (b > 0) {
            if ((b & 1) == 1) {
                res = (res + a) % mod;
            }
            a = (a << 1) % mod;
            b >>= 1;
        }
        return res;
    }

    static long modPow(long a, long e, long mod) {
        if (mod == 1)
            return 0;
        long r = 1 % mod;
        while (e > 0) {
            if ((e & 1) == 1)
                r = modMul(r, a, mod);
            a = modMul(a, a, mod);
            e >>= 1;
        }
        return r;
    }

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

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

        long[] bases = { 2, 325, 9375, 28178, 450775, 9780504, 1795265022 };
        for (long a : bases) {
            if (a % n == 0)
                continue;
            long x = modPow(a, d, n);
            if (x == 1 || x == n - 1)
                continue;
            boolean composite = true;
            for (int i = 1; i < s; i++) {
                x = modMul(x, x, n);
                if (x == n - 1) {
                    composite = false;
                    break;
                }
            }
            if (composite)
                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 Random rng = new Random(987654321L);

    static long pollardRho(long n) {
        if ((n & 1) == 0)
            return 2;

        while (true) {
            long c = (long) (rng.nextDouble() * n) % n;
            long x = (long) (rng.nextDouble() * n) % n;
            long y = x;
            long d = 1;

            while (d == 1) {
                x = (modMul(x, x, n) + c) % n;
                y = (modMul(y, y, n) + c) % n;
                y = (modMul(y, y, n) + c) % n;
                long diff = Math.abs(x - y);
                d = gcd(diff, n);
            }
            if (d != n)
                return d;
        }
    }

    static void factorRec(long n, Map<Long, Integer> out) {
        if (n == 1)
            return;
        if (isPrime(n)) {
            out.put(n, out.getOrDefault(n, 0) + 1);
            return;
        }
        long d = pollardRho(n);
        factorRec(d, out);
        factorRec(n / d, out);
    }

    static void genDivisors(List<long[]> pf, int idx, long cur, List<Long> out) {
        if (idx == pf.size()) {
            out.add(cur);
            return;
        }
        long p = pf.get(idx)[0];
        long e = pf.get(idx)[1];
        long v = 1;
        for (int i = 0; i <= e; i++) {
            genDivisors(pf, idx + 1, cur * v, out);
            v *= p;
        }
    }

    static List<Integer> primeFactorsDistinct(int n) {
        List<Integer> pf = new ArrayList<>();
        for (int p = 2; p * p <= n; p++) {
            if (n % p == 0) {
                pf.add(p);
                while (n % p == 0)
                    n /= p;
            }
        }
        if (n > 1)
            pf.add(n);
        return pf;
    }

    static boolean hasExactOrder(long mod, int ord, List<Integer> ordPrimes) {
        if (mod == 1)
            return false;
        if (modPow(2, ord, mod) != 1)
            return false;
        for (int p : ordPrimes) {
            if (modPow(2, ord / p, mod) == 1)
                return false;
        }
        return true;
    }

    static String sumNWithShuffleOrder(int ord) {
        long M = (1L << ord) - 1L;

        Map<Long, Integer> f = new TreeMap<>();
        factorRec(M, f);

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

        List<Long> divs = new ArrayList<>();
        genDivisors(pf, 0, 1, divs);

        List<Integer> ordPrimes = primeFactorsDistinct(ord);
        long sum = 0;
        for (long d : divs) {
            if (hasExactOrder(d, ord, ordPrimes)) {
                sum += (d + 1);
            }
        }
        return Long.toString(sum);
    }

    public static String solve() {
        return sumNWithShuffleOrder(60);
    }

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