#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll Pot(ll p, ll w)
{
    if (w == 0)
        return 1;
    if (w % 2 == 0)
    {
        ll pol = Pot(p, w / 2);
        return pol * pol % MOD;
    }
    return Pot(p, w - 1) * p % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> dp(k + 1);
    dp[k] = 1;
    for (ll i = k - 1; i >= 1; --i)
    {
        ll kan = (k - k % i) / i;
        dp[i] = Pot(kan, n);
        for (ll j = 2 * i; j <= k; j += i)
        {
            dp[i] -= dp[j];
            if (dp[i] < 0)
                dp[i] += MOD;
        }
    }
    ll odp = 0;
    for (ll i = 1; i <= k; ++i)
        odp = (odp + i * dp[i]) % MOD;
    cout << odp;
    return 0;
}
