import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

public class Euler843 {

    static class Poly {
        long lo, hi;

        Poly() {
            lo = 0;
            hi = 0;
        }

        Poly(long lo, long hi) {
            this.lo = lo;
            this.hi = hi;
        }

        boolean isZero() {
            return lo == 0 && hi == 0;
        }

        boolean isOne() {
            return lo == 1 && hi == 0;
        }

        Poly copy() {
            return new Poly(lo, hi);
        }
    }

    static Poly polyXor(Poly a, Poly b) {
        return new Poly(a.lo ^ b.lo, a.hi ^ b.hi);
    }

    static boolean polyEqual(Poly a, Poly b) {
        return a.lo == b.lo && a.hi == b.hi;
    }

    static int polyDegree(Poly p) {
        if (p.hi != 0)
            return 127 - Long.numberOfLeadingZeros(p.hi);
        if (p.lo != 0)
            return 63 - Long.numberOfLeadingZeros(p.lo);
        return -1;
    }

    static boolean polyGetBit(Poly p, int pos) {
        if (pos < 64)
            return ((p.lo >>> pos) & 1) != 0;
        return ((p.hi >>> (pos - 64)) & 1) != 0;
    }

    static void polyToggleBit(Poly p, int pos) {
        if (pos < 64)
            p.lo ^= (1L << pos);
        else
            p.hi ^= (1L << (pos - 64));
    }

    static Poly polyShiftLeft(Poly p, int k) {
        if (k == 0)
            return p.copy();
        if (k >= 64) {
            return new Poly(0, p.lo << (k - 64));
        }
        long hi = (p.hi << k) | (p.lo >>> (64 - k));
        long lo = p.lo << k;
        return new Poly(lo, hi);
    }

    static Poly polyShiftRight1(Poly p) {
        long lo = (p.lo >>> 1) | (p.hi << 63);
        long hi = p.hi >>> 1;
        return new Poly(lo, hi);
    }

    static Poly polyShiftLeft1(Poly p) {
        long hi = (p.hi << 1) | (p.lo >>> 63);
        long lo = p.lo << 1;
        return new Poly(lo, hi);
    }

    static Poly polyMod(Poly a, Poly mod) {
        int degMod = polyDegree(mod);
        if (degMod < 0)
            return a.copy();
        Poly aCpy = a.copy();
        while (true) {
            int degA = polyDegree(aCpy);
            if (degA < degMod)
                break;
            int shift = degA - degMod;
            aCpy = polyXor(aCpy, polyShiftLeft(mod, shift));
        }
        return aCpy;
    }

    static Poly polyDiv(Poly a, Poly mod) {
        Poly q = new Poly();
        int degMod = polyDegree(mod);
        Poly aCpy = a.copy();
        while (true) {
            int degA = polyDegree(aCpy);
            if (degA < degMod)
                break;
            int shift = degA - degMod;
            polyToggleBit(q, shift);
            aCpy = polyXor(aCpy, polyShiftLeft(mod, shift));
        }
        return q;
    }

    static Poly polyGcd(Poly a, Poly b) {
        Poly aCpy = a.copy();
        Poly bCpy = b.copy();
        while (!bCpy.isZero()) {
            Poly r = polyMod(aCpy, bCpy);
            aCpy = bCpy;
            bCpy = r;
        }
        return aCpy;
    }

    static Poly polyMulMod(Poly a, Poly b, Poly mod) {
        if (a.isZero() || b.isZero())
            return new Poly();
        Poly aCpy = polyMod(a, mod);
        Poly bCpy = polyMod(b, mod);
        int degMod = polyDegree(mod);
        Poly res = new Poly();

        while (!bCpy.isZero()) {
            if ((bCpy.lo & 1) != 0)
                res = polyXor(res, aCpy);
            bCpy = polyShiftRight1(bCpy);
            aCpy = polyShiftLeft1(aCpy);
            if (polyGetBit(aCpy, degMod))
                aCpy = polyXor(aCpy, mod);
        }
        return res;
    }

    static Poly polyPowMod(Poly base, long exp, Poly mod) {
        Poly res = new Poly(1, 0);
        Poly baseCpy = base.copy();
        while (exp > 0) {
            if ((exp & 1) != 0)
                res = polyMulMod(res, baseCpy, mod);
            baseCpy = polyMulMod(baseCpy, baseCpy, mod);
            exp >>>= 1;
        }
        return res;
    }

    static ArrayList<Integer> sievePrimes(int limit) {
        boolean[] isPrime = new boolean[limit + 1];
        java.util.Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i * i <= limit; ++i) {
            if (!isPrime[i])
                continue;
            for (int j = i * i; j <= limit; j += i)
                isPrime[j] = false;
        }
        ArrayList<Integer> primes = new ArrayList<>();
        for (int i = 2; i <= limit; ++i) {
            if (isPrime[i])
                primes.add(i);
        }
        return primes;
    }

    static ArrayList<Long> factorizeUint64(long n, ArrayList<Integer> primes) {
        ArrayList<Long> factors = new ArrayList<>();
        long temp = n;
        for (int p : primes) {
            long pp = p;
            if (pp * pp > temp)
                break;
            if (temp % pp == 0) {
                factors.add(pp);
                while (temp % pp == 0)
                    temp /= pp;
            }
        }
        if (temp > 1)
            factors.add(temp);
        return factors;
    }

    static ArrayList<Poly> berlekampFactor(Poly f) {
        int m = polyDegree(f);
        ArrayList<Poly> resf = new ArrayList<>();
        if (m <= 1) {
            resf.add(f.copy());
            return resf;
        }

        Poly[] rows = new Poly[m];
        for (int i = 0; i < m; i++)
            rows[i] = new Poly();

        Poly xPoly = new Poly(2, 0);
        Poly x2 = polyMulMod(xPoly, xPoly, f);
        Poly power = new Poly(1, 0);

        for (int col = 0; col < m; ++col) {
            for (int row = 0; row < m; ++row) {
                if (polyGetBit(power, row)) {
                    polyToggleBit(rows[row], col);
                }
            }
            power = polyMulMod(power, x2, f);
        }
        for (int i = 0; i < m; ++i)
            polyToggleBit(rows[i], i);

        ArrayList<Integer> pivotCol = new ArrayList<>();
        int rank = 0;
        for (int col = 0; col < m; ++col) {
            int sel = -1;
            for (int r = rank; r < m; ++r) {
                if (polyGetBit(rows[r], col)) {
                    sel = r;
                    break;
                }
            }
            if (sel == -1)
                continue;
            Poly tmp = rows[rank];
            rows[rank] = rows[sel];
            rows[sel] = tmp;
            pivotCol.add(col);
            for (int r = 0; r < m; ++r) {
                if (r != rank && polyGetBit(rows[r], col)) {
                    rows[r] = polyXor(rows[r], rows[rank]);
                }
            }
            ++rank;
        }

        boolean[] isPivot = new boolean[m];
        for (int i = 0; i < rank; ++i)
            isPivot[pivotCol.get(i)] = true;

        ArrayList<Poly> basis = new ArrayList<>();
        for (int col = 0; col < m; ++col) {
            if (isPivot[col])
                continue;
            Poly vec = new Poly();
            polyToggleBit(vec, col);
            for (int i = 0; i < rank; ++i) {
                int p = pivotCol.get(i);
                if (polyGetBit(rows[i], col))
                    polyToggleBit(vec, p);
            }
            basis.add(vec);
        }

        ArrayList<Poly> factors = new ArrayList<>();
        factors.add(f.copy());

        for (Poly b : basis) {
            if (b.isZero() || b.isOne())
                continue;
            ArrayList<Poly> nextFactors = new ArrayList<>();
            for (Poly h : factors) {
                if (polyDegree(h) <= 1) {
                    nextFactors.add(h);
                    continue;
                }
                Poly g = polyGcd(h, b);
                if (!g.isOne() && !polyEqual(g, h)) {
                    Poly q = polyDiv(h, g);
                    nextFactors.add(g);
                    nextFactors.add(q);
                    continue;
                }
                Poly b1 = b.copy();
                polyToggleBit(b1, 0);
                g = polyGcd(h, b1);
                if (!g.isOne() && !polyEqual(g, h)) {
                    Poly q = polyDiv(h, g);
                    nextFactors.add(g);
                    nextFactors.add(q);
                } else {
                    nextFactors.add(h);
                }
            }
            factors = nextFactors;
        }

        return factors;
    }

    static long orderInFactor(Poly lambda, Poly mod, ArrayList<Integer> primes) {
        if (lambda.isZero())
            return 0;
        if (lambda.isOne())
            return 1;

        int deg = polyDegree(mod);
        Poly cur = lambda.copy();
        int e = 0;
        do {
            cur = polyMulMod(cur, cur, mod);
            ++e;
        } while (!polyEqual(cur, lambda) && e <= deg);

        long order = (e >= 64) ? -1L : ((1L << e) - 1L);
        long reduced = order;
        ArrayList<Long> factors = factorizeUint64(order, primes);

        for (long p : factors) {
            while (reduced % p == 0) {
                long trial = reduced / p;
                if (polyPowMod(lambda, trial, mod).isOne()) {
                    reduced = trial;
                } else {
                    break;
                }
            }
        }
        return reduced;
    }

    static ArrayList<Long> computeOrdersForM(int m, ArrayList<Integer> primes) {
        Poly f = new Poly(1, 0);
        polyToggleBit(f, m);

        ArrayList<Poly> factors = berlekampFactor(f);
        ArrayList<Long> orders = new ArrayList<>();
        Poly xPoly = new Poly(2, 0);

        for (Poly g : factors) {
            Poly xPow = polyPowMod(xPoly, m - 1, g);
            Poly lambda = polyXor(xPoly, xPow);
            lambda = polyMod(lambda, g);
            orders.add(orderInFactor(lambda, g, primes));
        }
        return orders;
    }

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

    static long lcm(long a, long b) {
        return (a / gcd(a, b)) * b;
    }

    static HashSet<Long> periodsForN(int n, ArrayList<Long> orders, int k) {
        HashSet<Long> periods = new HashSet<>();
        periods.add(1L);

        for (long ord : orders) {
            ArrayList<Long> opts = new ArrayList<>();
            opts.add(1L);
            if (ord == 0) {
            } else if (ord == 1) {
                for (int s = 1; s <= k; ++s)
                    opts.add(1L << s);
            } else {
                for (int s = 0; s <= k; ++s)
                    opts.add(ord << s);
            }

            HashSet<Long> nextPeriods = new HashSet<>();
            for (long p : periods) {
                for (long o : opts) {
                    nextPeriods.add(lcm(p, o));
                }
            }
            periods = nextPeriods;
        }
        return periods;
    }

    static long computeS(int N, ArrayList<Integer> primes) {
        HashMap<Integer, ArrayList<Long>> orderCache = new HashMap<>();
        HashSet<Long> globalPeriods = new HashSet<>();

        for (int n = 3; n <= N; ++n) {
            int m = n;
            int k = 0;
            while ((m & 1) == 0) {
                m >>= 1;
                ++k;
            }
            if (!orderCache.containsKey(m)) {
                orderCache.put(m, computeOrdersForM(m, primes));
            }
            HashSet<Long> per = periodsForN(n, orderCache.get(m), k);
            globalPeriods.addAll(per);
        }

        long sum = 0;
        for (long v : globalPeriods)
            sum += v;
        return sum;
    }

    public static String solve() {
        ArrayList<Integer> primes = sievePrimes(5000000);
        return Long.toString(computeS(100, primes));
    }

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