#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;

ll modnum = 1e9+7;

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


int main() {
    ll n,k; cin >> n >> k;
    ll ans = 0;

    vector<ll> count(k+10, 0);
    for(ll i=k; i > 0; i--) {
        ll num = k/i;
        ll tmp = modpow(num, n, modnum);
        count[i] = tmp;
        ll ii = i*2;
        while(ii <= k) {
            count[i] -= count[ii];
            ii += i;
        }
    }


    EFOR(i,1, k) {
        ans += i*count[i]%modnum;
        ans %= modnum;
    }



    cout << ans << endl;
    return 0;
}
