# ABC162

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

"""

3 2

->9

3 200

->10813692

100000 100000

->742202979

"""

ans = 0

xl=[0]*(k+1)

MOD = int(1e+9 + 7)



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

    xl[x] = pow(k // x,n, MOD) 



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

    xl[x] -= sum([xl[i*x] for i in range(2,1 + k//x)])



ans = 0

for i in range(k+1):

    ans += i * xl[i]



print((ans % MOD))

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

# 1以上k以下の整数がn個

mod=int(1e+9 + 7)

d=[0]*(k+1)

ans=0

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

      m=k//i

      d[i]=pow(m,n, mod) 

      d[i]-=sum([d[j*i]for j in range(2,m+1)])

      ans+=(d[i]*i)%mod

print(((ans)%mod))

#print(d)



# ABC162
n, k = list(map(int, input().split()))
"""
3 2
->9
3 200
->10813692
100000 100000
->742202979
"""
ans = 0
xl = [0] * (k + 1)
MOD = int(1e9 + 7)
for x in range(k, 0, -1):
    xl[x] = pow(k // x, n, MOD)
for x in range(k, 0, -1):
    xl[x] -= sum([xl[i * x] for i in range(2, 1 + k // x)])
ans = 0
for i in range(k + 1):
    ans += i * xl[i]
print((ans % MOD))

n, k = list(map(int, input().split()))
# 1以上k以下の整数がn個
mod = int(1e9 + 7)
d = [0] * (k + 1)
ans = 0
for i in range(k, 0, -1):
    m = k // i
    d[i] = pow(m, n, mod)
    d[i] -= sum([d[j * i] for j in range(2, m + 1)])
    ans += (d[i] * i) % mod
print(((ans) % mod))
# print(d)

-# ABC162 -""" -3 2 -->9 -3 200 -->10813692 -100000 100000 -->742202979 -""" +# 1以上k以下の整数がn個 +mod = int(1e9 + 7) +d = [0] * (k + 1) -xl = [0] * (k + 1) -MOD = int(1e9 + 7) -for x in range(k, 0, -1): -    xl[x] = pow(k // x, n, MOD) -for x in range(k, 0, -1): -    xl[x] -= sum([xl[i * x] for i in range(2, 1 + k // x)]) -ans = 0 -for i in range(k + 1): -    ans += i * xl[i] -print((ans % MOD)) +for i in range(k, 0, -1): +    m = k // i +    d[i] = pow(m, n, mod) +    d[i] -= sum([d[j * i] for j in range(2, m + 1)]) +    ans += (d[i] * i) % mod +print(((ans) % mod)) +# print(d)