#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}

int main(){
    ll N,K;
    string S;
    cin >> N >> K;
    vector<ll> d(K+1);
    if(K == 1){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 1;i<=K;i++){
        d[i] = mpow(K/i, N);
        //cout << d[i] << " ";     
    }
    //cout << endl;
    for(int i = K;0 < i;i--){
        for(int j = 2; i*j <= K; j++){
            d[i] -= d[i*j];
        }
    }

    ll ans = 0;
    for(int i = 1;i<=K;i++){
        ans += (d[i]*i) % mo;
        ans %= mo;
    }
    cout << ans << endl;
        /*
        auto v = factorize(i);
        sum += N;7 
        rep(j,v.size()){
            rep(k, v[j].second){
                sum += ((i / pow(v[j].first, k+1)))*v[j].first;
            }
        }
    }
    cout << sum <<endl;
*/
}