@staticmethod
def d():
    (n, k) = map(int, sys.stdin.readline().split())
    div = sorted(NumberTheory.find_divisors(k))
    l = len(div)
    s = ([0] * l)
    for (i, d) in enumerate(div):
        s[i] = (((((1 + (n // d)) * (n // d)) // 2) * d) % MOD)
    for i in range((l - 1), (- 1), (- 1)):
        for j in range((i + 1), l):
            if (div[j] % div[i]):
                continue
            s[i] = ((s[i] - s[j]) % MOD)
    print((sum(((((s[i] * k) // div[i]) % MOD) for i in range(l))) % MOD))
@staticmethod
def d():
    (n, k) = map(int, sys.stdin.readline().split())
    div = sorted(NumberTheory.find_divisors(k))
    l = len(div)
    s = ([0] * l)
    for (i, d) in enumerate(div):
        s[i] = (((((1 + (n // d)) * (n // d)) // 2) * d) % MOD)
    for i in range((l - 1), (- 1), (- 1)):
        for j in range((i + 1), l):
            if (div[j] % div[i]):
                continue
            s[i] = ((s[i] - s[j]) % MOD)
    print((sum(((((s[i] * k) // div[i]) % MOD) for i in range(l))) % MOD))