#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
template <std::uint_fast64_t Modulus>
class modint
{
    using u64 = std::uint_fast64_t;

public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept
    {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept
    {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept
    {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept
    {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept
    {
        a += rhs.a;
        if (a >= Modulus)
        {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept
    {
        if (a < rhs.a)
        {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept
    {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept
    {
        u64 exp = Modulus - 2;
        while (exp)
        {
            if (exp % 2)
            {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
#define M 1000000007

ll powmod(ll a, ll b)
{
    if (b == 1)
    {
        return a;
    }
    else if (b % 2 == 0)
    {
        return powmod((a * a) % M, b / 2);
    }
    else
    {
        return (a * powmod((a * a) % M, b / 2)) % M;
    }
}
int main()
{
    /*    int n, k;
    cin >> n >> k;
    vector<modint<M>> v(k, 0);
    for (int i = k; i > 0; i--)
    {
        modint<M> a = 1;
        int m = k / i;
        rep(j, n)
        {
            a *= m;
        }
        v[i - 1] = a;
        for (int j = 2 * i; j <= k; j += i)
        {
            v[i - 1] -= v[j - 1];
        }
        cout << v[i - 1].a << endl;
    }
    modint<M> ans = 0;
    for (modint<M> i = 0; i.a < k; i += 1)
    {
        ans += (i.a + 1) * v[i.a].a;
        //        cout << i.a << endl;
    }
    cout << ans.a << endl;
    */
    int n, k;
    cin >> n >> k;
    vector<ll> v(k, 0);
    for (int i = k; i > 0; i--)
    {
        ll a = 1;
        int m = k / i;
        a = powmod(m, n);
        // rep(j, n)
        // {
        //     a *= m;
        //     a %= M;
        // }
        v[i - 1] = a;
        for (int j = 2 * i; j <= k; j += i)
        {
            v[i - 1] -= v[j - 1];
        }
        v[i - 1] %= M;
        //        cout << v[i - 1] << endl;
    }
    ll ans = 0;
    for (int i = 0; i < k; i += 1)
    {
        ans += (i + 1) * v[i];
        ans %= M;
        //        cout << i.a << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052