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)



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

mod=pow(10,9)+7

ans=[0]*(k+1)

# gcdがkiとなる数列。すべてがkiの倍数でかつ少なくとも一つkiを含む

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

    a=k//ki

    ans[ki]=pow(a,n,mod)

    i=2

    while i*ki<=k:

        ans[ki]-=ans[i*ki]

        i+=1

b=0

for ki in range(1,k+1):

    b+=(ans[ki]*ki)%mod

    b%=mod

print(b)

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)

n, k = list(map(int, input().split()))
mod = pow(10, 9) + 7
ans = [0] * (k + 1)
# gcdがkiとなる数列。すべてがkiの倍数でかつ少なくとも一つkiを含む
for ki in range(k, 0, -1):
    a = k // ki
    ans[ki] = pow(a, n, mod)
    i = 2
    while i * ki <= k:
        ans[ki] -= ans[i * ki]
        i += 1
b = 0
for ki in range(1, k + 1):
    b += (ans[ki] * ki) % mod
    b %= mod
print(b)

-# 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) +mod = pow(10, 9) + 7 +ans = [0] * (k + 1) +# gcdがkiとなる数列。すべてがkiの倍数でかつ少なくとも一つkiを含む +for ki in range(k, 0, -1): +    a = k // ki +    ans[ki] = pow(a, n, mod) +    i = 2 +    while i * ki <= k: +        ans[ki] -= ans[i * ki] +        i += 1 +b = 0 +for ki in range(1, k + 1): +    b += (ans[ki] * ki) % mod +    b %= mod +print(b)