def factorization(n):

    arr = []

    temp = n

    for i in range(2, int(-(-n**0.5//1))+1):

        if temp%i==0:

            cnt=0

            while temp%i==0:

                cnt+=1

                temp //= i

            arr.append([i, cnt])



    if temp!=1:

        arr.append([temp, 1])



    if arr==[]:

        arr.append([n, 1])



    return arr



import numpy as np

M = int(10**9)+7

n,k = [int(c) for c in input().split()]

nums = [0]*(k+1)

nums = np.zeros((k+1), dtype=int)

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

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

    tmp -= nums[(2*i)::i].sum()

    nums[i] += tmp

    

# print(sum((i)*nums[i]%M for i in range(len(nums)))%M)

print(((np.arange(k+1) * nums).sum()%M))
def factorization(n):

    arr = []

    temp = n

    for i in range(2, int(-(-n**0.5//1))+1):

        if temp%i==0:

            cnt=0

            while temp%i==0:

                cnt+=1

                temp //= i

            arr.append([i, cnt])



    if temp!=1:

        arr.append([temp, 1])



    if arr==[]:

        arr.append([n, 1])



    return arr



M = int(10**9)+7

n,k = [int(c) for c in input().split()]

nums = [0]*(k+1)

# nums = np.zeros((k+1), dtype=int)

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

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

    tmp -= sum(nums[(2*i)::i])

    nums[i] += tmp

    

print((sum((i)*nums[i]%M for i in range(len(nums)))%M))

# print((np.arange(k+1) * nums).sum()%M)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-(n**0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


import numpy as np

M = int(10**9) + 7
n, k = [int(c) for c in input().split()]
nums = [0] * (k + 1)
nums = np.zeros((k + 1), dtype=int)
for i in range(k, 0, -1):
    tmp = pow(k // i, n, M)
    tmp -= nums[(2 * i) :: i].sum()
    nums[i] += tmp
# print(sum((i)*nums[i]%M for i in range(len(nums)))%M)
print(((np.arange(k + 1) * nums).sum() % M))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-(n**0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


M = int(10**9) + 7
n, k = [int(c) for c in input().split()]
nums = [0] * (k + 1)
# nums = np.zeros((k+1), dtype=int)
for i in range(k, 0, -1):
    tmp = pow(k // i, n, M)
    tmp -= sum(nums[(2 * i) :: i])
    nums[i] += tmp
print((sum((i) * nums[i] % M for i in range(len(nums))) % M))
# print((np.arange(k+1) * nums).sum()%M)

-import numpy as np - -nums = np.zeros((k + 1), dtype=int) +# nums = np.zeros((k+1), dtype=int) -    tmp -= nums[(2 * i) :: i].sum() +    tmp -= sum(nums[(2 * i) :: i]) -# print(sum((i)*nums[i]%M for i in range(len(nums)))%M) -print(((np.arange(k + 1) * nums).sum() % M)) +print((sum((i) * nums[i] % M for i in range(len(nums))) % M)) +# print((np.arange(k+1) * nums).sum()%M)