#include <bits/stdc++.h>
using namespace std;

using LL = long long;
const LL MOD = 1e9+7;

LL modpow(LL a, LL n) {
    LL ret = 1, tmp = a;
    while (n) {
        if (n & 1) (ret *= tmp) %= MOD;
        (tmp *= tmp) %= MOD;
        n >>= 1;
    }
    return ret;
}


int main()
{
    // O(KlogN + KloglogK)

    int N, K; cin >> N >> K;

    vector<LL> f(K+1);
    for (int d = 1; d <= K; ++d) {
        f[d] = modpow(K / d, N);
    }

    vector<bool> isprime(K+1, true);
    for (int p = 2; p <= K; ++p) {
        if (!isprime[p]) continue;
        for (int i = 1; i * p <= K; ++i) {
            isprime[i * p] = false;
            (f[i] -= f[i * p]) %= MOD;
            if (f[i] < 0) f[i] += MOD;
        }
    }

    LL ans = 0;
    for (int d = 1; d <= K; ++d) {
        (ans += f[d] * d) %= MOD;
    }

    cout << ans << endl;

    return 0;
}
