import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

import numpy as np



MOD = 10**9 + 7

N, K = list(map(int, read().split()))



is_prime = np.zeros(K + 10, np.bool)

is_prime[2] = 1

is_prime[3::2] = 1

for p in range(3, K + 10, 2):

    if p * p > K:

        break

    if is_prime[p]:

        is_prime[p * p:: p + p] = 0

primes = np.where(is_prime)[0]





A = [0] * (K + 1)

for d in range(1, K + 1):

    A[d] = pow(K // d, N, MOD)



for p in primes.tolist():

    for i in range(K // p + 1):

        A[i] -= A[i * p]



answer = sum(i * x for i, x in enumerate(A))

print((answer % MOD))

N, K = list(map(int, input().split()))

MOD = 10**9 + 7



M = int(K ** .5)

f_l = [0] * (M+1)  # f(k)

f_h = [0] * (M+1)  # f(K//d)



def f(k):

  return f_l[k] if k <= M else f_h[K//k]



def compute_f(k):

  x = pow(k, N, MOD)

  sq = int(k ** .5)

  for d in range(2, k+1):

    n = k // d

    if n <= sq:

      break

    x -= f(n)

  for n in range(1, sq+1):

    cnt = k//n - k//(n+1)

    x -= f_l[n] * cnt

  return x



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

  f_l[k] = compute_f(k)



for d in range(M, 0, -1):

  f_h[d] = compute_f(K//d)



answer = 0



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

  low_d = K // (k+1) + 1

  high_d = K // k

  items = high_d - low_d + 1

  coef = (low_d + high_d) * items // 2

  answer += coef * f_l[k]

  

for d in range(1, M+1):

  if K // d <= M:

    break

  answer += d * f_h[d]



answer %= MOD

print(answer)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

MOD = 10**9 + 7
N, K = list(map(int, read().split()))
is_prime = np.zeros(K + 10, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, K + 10, 2):
    if p * p > K:
        break
    if is_prime[p]:
        is_prime[p * p :: p + p] = 0
primes = np.where(is_prime)[0]
A = [0] * (K + 1)
for d in range(1, K + 1):
    A[d] = pow(K // d, N, MOD)
for p in primes.tolist():
    for i in range(K // p + 1):
        A[i] -= A[i * p]
answer = sum(i * x for i, x in enumerate(A))
print((answer % MOD))

N, K = list(map(int, input().split()))
MOD = 10**9 + 7
M = int(K**0.5)
f_l = [0] * (M + 1)  # f(k)
f_h = [0] * (M + 1)  # f(K//d)


def f(k):
    return f_l[k] if k <= M else f_h[K // k]


def compute_f(k):
    x = pow(k, N, MOD)
    sq = int(k**0.5)
    for d in range(2, k + 1):
        n = k // d
        if n <= sq:
            break
        x -= f(n)
    for n in range(1, sq + 1):
        cnt = k // n - k // (n + 1)
        x -= f_l[n] * cnt
    return x


for k in range(1, M + 1):
    f_l[k] = compute_f(k)
for d in range(M, 0, -1):
    f_h[d] = compute_f(K // d)
answer = 0
for k in range(1, M + 1):
    low_d = K // (k + 1) + 1
    high_d = K // k
    items = high_d - low_d + 1
    coef = (low_d + high_d) * items // 2
    answer += coef * f_l[k]
for d in range(1, M + 1):
    if K // d <= M:
        break
    answer += d * f_h[d]
answer %= MOD
print(answer)

-import sys +N, K = list(map(int, input().split())) +MOD = 10**9 + 7 +M = int(K**0.5) +f_l = [0] * (M + 1)  # f(k) +f_h = [0] * (M + 1)  # f(K//d) -read = sys.stdin.buffer.read -readline = sys.stdin.buffer.readline -readlines = sys.stdin.buffer.readlines -import numpy as np -MOD = 10**9 + 7 -N, K = list(map(int, read().split())) -is_prime = np.zeros(K + 10, np.bool) -is_prime[2] = 1 -is_prime[3::2] = 1 -for p in range(3, K + 10, 2): -    if p * p > K: +def f(k): +    return f_l[k] if k <= M else f_h[K // k] + + +def compute_f(k): +    x = pow(k, N, MOD) +    sq = int(k**0.5) +    for d in range(2, k + 1): +        n = k // d +        if n <= sq: +            break +        x -= f(n) +    for n in range(1, sq + 1): +        cnt = k // n - k // (n + 1) +        x -= f_l[n] * cnt +    return x + + +for k in range(1, M + 1): +    f_l[k] = compute_f(k) +for d in range(M, 0, -1): +    f_h[d] = compute_f(K // d) +answer = 0 +for k in range(1, M + 1): +    low_d = K // (k + 1) + 1 +    high_d = K // k +    items = high_d - low_d + 1 +    coef = (low_d + high_d) * items // 2 +    answer += coef * f_l[k] +for d in range(1, M + 1): +    if K // d <= M: -    if is_prime[p]: -        is_prime[p * p :: p + p] = 0 -primes = np.where(is_prime)[0] -A = [0] * (K + 1) -for d in range(1, K + 1): -    A[d] = pow(K // d, N, MOD) -for p in primes.tolist(): -    for i in range(K // p + 1): -        A[i] -= A[i * p] -answer = sum(i * x for i, x in enumerate(A)) -print((answer % MOD)) +    answer += d * f_h[d] +answer %= MOD +print(answer)