#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

//繰り返し二乗法
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	ll n;cin>>n;
	ll k;cin>>k;
	vector<ll> a(k + 1);
	for(ll i = 1; i <= k; i++) {
		a[i] = mod_pow((k / i),n);
	}
	ll ans = 0;
	vector<ll> cnt(k + 1);
	for(ll i = k; i >= 1; i--) {
		ll tmp = a[i];
		ll x = 2;
		while(x * i<= k){
			tmp -= cnt[x * i];
			x++;
		}
		cnt[i] = tmp;
	}
	for(ll i = 1; i <= k; i++) {
		ans += (i * cnt[i]);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}