import numpy as np

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

m = 10**9 + 7

gcds = np.zeros(k+1, int)



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

  tmp = k // i

  gcds[i] = pow(tmp,n, m)

  for j in range(tmp,1,-1):

    gcds[i] -= gcds[j*i]

ans = 0

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

  ans = (ans + gcds[i]*i)%m

print(ans)
import numpy as np

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

m = 10**9 + 7

gcds = np.zeros(k+1, int)

ans = 0



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

  tmp = pow(k//i,n, m)

  for j in range(i*2,k+1,i):

    tmp -= gcds[j]

  ans = (ans + tmp*i)%m

  gcds[i] = tmp

print(ans)
import numpy as np

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

import numpy as np

n, k = list(map(int, input().split()))
m = 10**9 + 7
gcds = np.zeros(k + 1, int)
ans = 0
for i in range(k, 0, -1):
    tmp = pow(k // i, n, m)
    for j in range(i * 2, k + 1, i):
        tmp -= gcds[j]
    ans = (ans + tmp * i) % m
    gcds[i] = tmp
print(ans)

-for i in range(k, 0, -1): -    tmp = k // i -    gcds[i] = pow(tmp, n, m) -    for j in range(tmp, 1, -1): -        gcds[i] -= gcds[j * i] -    ans = (ans + gcds[i] * i) % m +    tmp = pow(k // i, n, m) +    for j in range(i * 2, k + 1, i): +        tmp -= gcds[j] +    ans = (ans + tmp * i) % m +    gcds[i] = tmp