def divisors(n):

    ret=[]

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

        if n%i==0:

            ret.append(i)

            if i!=n//i:

                ret.append(n//i)

    return ret



mod=10**9+7    

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

cnt=[0]*(k+1)

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

    divs=divisors(i)

    cnt[i]+=pow(k//i,n,mod)

    for val in divs:

        if val==i:

            continue

        else:

            cnt[val]-=cnt[i]

cnt[1]+=pow(k,n,mod)

ans=0

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

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

    ans%=mod

print(ans)
mod=10**9+7    

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

cnt=[0]*(k+1)

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

    cnt[i]+=pow(k//i,n,mod)

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

      cnt[i]-=cnt[i*j]

ans=0

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

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

    ans%=mod

print(ans)
def divisors(n):
    ret = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ret.append(i)
            if i != n // i:
                ret.append(n // i)
    return ret


mod = 10**9 + 7
n, k = list(map(int, input().split()))
cnt = [0] * (k + 1)
for i in range(k, 1, -1):
    divs = divisors(i)
    cnt[i] += pow(k // i, n, mod)
    for val in divs:
        if val == i:
            continue
        else:
            cnt[val] -= cnt[i]
cnt[1] += pow(k, n, mod)
ans = 0
for i in range(1, k + 1):
    ans += i * (cnt[i]) % mod
    ans %= mod
print(ans)

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

-def divisors(n): -    ret = [] -    for i in range(1, int(n**0.5) + 1): -        if n % i == 0: -            ret.append(i) -            if i != n // i: -                ret.append(n // i) -    return ret - - -for i in range(k, 1, -1): -    divs = divisors(i) +for i in range(k, 0, -1): -    for val in divs: -        if val == i: -            continue -        else: -            cnt[val] -= cnt[i] -cnt[1] += pow(k, n, mod) +    for j in range(2, k // i + 1): +        cnt[i] -= cnt[i * j]