import sys



input = sys.stdin.readline

P = 10 ** 9 + 7





def main():

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



    ans = 0

    n_gcd = [0] * (K + 1)

    for k in reversed(list(range(1, K + 1))):

        n_gcd[k] = pow(K // k, N, mod=P)

        for m in range(2, K // k + 1):

            n_gcd[k] -= n_gcd[k * m]

        n_gcd[k] %= P

        ans = (ans + k * n_gcd[k]) % P



    print(ans)





if __name__ == "__main__":

    main()

import sys



input = sys.stdin.readline

P = 10 ** 9 + 7





def main():

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



    ans = 0

    n_gcd = [0] * (K + 1)

    for k in reversed(list(range(1, K + 1))):

        n = pow(K // k, N, mod=P)

        for m in range(2, K // k + 1):

            n -= n_gcd[k * m]

        n_gcd[k] = n % P

        ans = (ans + k * n_gcd[k]) % P



    print(ans)





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline
P = 10**9 + 7


def main():
    N, K = list(map(int, input().split()))
    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n_gcd[k] = pow(K // k, N, mod=P)
        for m in range(2, K // k + 1):
            n_gcd[k] -= n_gcd[k * m]
        n_gcd[k] %= P
        ans = (ans + k * n_gcd[k]) % P
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
P = 10**9 + 7


def main():
    N, K = list(map(int, input().split()))
    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n = pow(K // k, N, mod=P)
        for m in range(2, K // k + 1):
            n -= n_gcd[k * m]
        n_gcd[k] = n % P
        ans = (ans + k * n_gcd[k]) % P
    print(ans)


if __name__ == "__main__":
    main()

-        n_gcd[k] = pow(K // k, N, mod=P) +        n = pow(K // k, N, mod=P) -            n_gcd[k] -= n_gcd[k * m] -        n_gcd[k] %= P +            n -= n_gcd[k * m] +        n_gcd[k] = n % P