#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

ll pow(ll x,ll n){  // xのn乗 (mod m)
    ll res = 1;
    if(n > 0){
        res = pow(x,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }else{
            res = (((res * res) % mod) * x) % mod;
        }
    }
    return res;
}

int main()
{
    ll n,k;  cin >> n >> k;
    ll ans = 0;
    ll cnt[k+1];   // sub[i] := iのときのgcdの数
    rep(i,k+1) cnt[i] = 0;

    for(int i = k; i >= 1; i--){
        cnt[i] = pow(k/i,n);
        for(int j = 2 * i; j < k + 1; j += i){
            cnt[i] -= cnt[j];
        }
    }
    //rep(i,k+1) cout <<cnt[i] << endl;

    for(int i = k; i >= 1; i--){
        ans += ( i * cnt[i] );
        //cout << i << ':' << pow((k/i),n) - pow((k/i)-1,n) << endl;
        ans %= mod;
    }
    cout << ans << endl;
}
