import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7



N, K = list(map(int, read().split()))



A = [0] * (K + 1)

for d in range(1, K + 1):

    A[d] = pow(K // d, N, MOD)



for d in range(K, 0, -1):

    for i in range(2, K // d + 1):

        A[d] -= A[d * i]



answer = sum(d * x for d, x in enumerate(A))

print((answer % MOD))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

import numpy as np



MOD = 10**9 + 7

N, K = list(map(int, read().split()))



is_prime = np.zeros(K + 10, np.bool)

is_prime[2] = 1

is_prime[3::2] = 1

for p in range(3, K + 10, 2):

    if p * p > K:

        break

    if is_prime[p]:

        is_prime[p * p:: p + p] = 0

primes = np.where(is_prime)[0]





A = [0] * (K + 1)

for d in range(1, K + 1):

    A[d] = pow(K // d, N, MOD)



for p in primes.tolist():

    for i in range(K // p + 1):

        A[i] -= A[i * p]



answer = sum(i * x for i, x in enumerate(A))

print((answer % MOD))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9 + 7
N, K = list(map(int, read().split()))
A = [0] * (K + 1)
for d in range(1, K + 1):
    A[d] = pow(K // d, N, MOD)
for d in range(K, 0, -1):
    for i in range(2, K // d + 1):
        A[d] -= A[d * i]
answer = sum(d * x for d, x in enumerate(A))
print((answer % MOD))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

MOD = 10**9 + 7
N, K = list(map(int, read().split()))
is_prime = np.zeros(K + 10, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, K + 10, 2):
    if p * p > K:
        break
    if is_prime[p]:
        is_prime[p * p :: p + p] = 0
primes = np.where(is_prime)[0]
A = [0] * (K + 1)
for d in range(1, K + 1):
    A[d] = pow(K // d, N, MOD)
for p in primes.tolist():
    for i in range(K // p + 1):
        A[i] -= A[i * p]
answer = sum(i * x for i, x in enumerate(A))
print((answer % MOD))

+import numpy as np + +is_prime = np.zeros(K + 10, np.bool) +is_prime[2] = 1 +is_prime[3::2] = 1 +for p in range(3, K + 10, 2): +    if p * p > K: +        break +    if is_prime[p]: +        is_prime[p * p :: p + p] = 0 +primes = np.where(is_prime)[0] -for d in range(K, 0, -1): -    for i in range(2, K // d + 1): -        A[d] -= A[d * i] -answer = sum(d * x for d, x in enumerate(A)) +for p in primes.tolist(): +    for i in range(K // p + 1): +        A[i] -= A[i * p] +answer = sum(i * x for i, x in enumerate(A))