#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MAX = ll(1e9) + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<ll> cnt(K+1);
    for(int i = K; i > 0; i--) {
        cnt[i] = modpow(ll(K/i), ll(N), MAX);
        repSE(j,2,K/i+1) {
            cnt[i] = (cnt[i] - cnt[j*i]) % MAX;
        }
        ans = (ans + ll(cnt[i] * i)) % MAX;
    }
    if (ans < 0) ans += MAX;
    cout << ans << endl;
    return 0;
}
