# 解説AC

mod = 10 ** 9 + 7

n, k = list(map(int, input().split()))

dp = [-1] * (k + 1)

ans = 0

for i in range(k, 0, -1):

    dp[i] = pow(k // i, n, mod)

    t = 0

    t += 2 * i

    while t <= k:

        dp[i] -= dp[t]

        dp[i] %= mod

        t += i

    ans += i * dp[i]

    ans %= mod

print(ans)

n, k = list(map(int, input().split()))

mod = 10 ** 9 + 7

dp = [0] * (k + 1)

ans = 0

for i in range(k, 0, -1):

    num = k // i

    dp[i] += pow(num, n, mod)



    for j in range(1, num):

        dp[i] -= dp[(j + 1) * i]

    ans += i * dp[i]

    ans %= mod

print(ans)

# 解説AC
mod = 10**9 + 7
n, k = list(map(int, input().split()))
dp = [-1] * (k + 1)
ans = 0
for i in range(k, 0, -1):
    dp[i] = pow(k // i, n, mod)
    t = 0
    t += 2 * i
    while t <= k:
        dp[i] -= dp[t]
        dp[i] %= mod
        t += i
    ans += i * dp[i]
    ans %= mod
print(ans)

n, k = list(map(int, input().split()))
mod = 10**9 + 7
dp = [0] * (k + 1)
ans = 0
for i in range(k, 0, -1):
    num = k // i
    dp[i] += pow(num, n, mod)
    for j in range(1, num):
        dp[i] -= dp[(j + 1) * i]
    ans += i * dp[i]
    ans %= mod
print(ans)

-# 解説AC +n, k = list(map(int, input().split())) -n, k = list(map(int, input().split())) -dp = [-1] * (k + 1) +dp = [0] * (k + 1) -    dp[i] = pow(k // i, n, mod) -    t = 0 -    t += 2 * i -    while t <= k: -        dp[i] -= dp[t] -        dp[i] %= mod -        t += i +    num = k // i +    dp[i] += pow(num, n, mod) +    for j in range(1, num): +        dp[i] -= dp[(j + 1) * i]