#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

const ll mod = 1e9 + 7;

long long gcd(ll x, ll y){
	if(x > y) swap(x, y);
	while(x != 0){
		y %= x;
		swap(x, y);
	}
	return y;
}

ll mpow(ll x, ll r){
	if(r == 0) return 1;
	if(r % 2 == 1){ return x * mpow(x, r-1) % mod; }
	else{ ll aa = mpow(x, r/2); return aa*aa%mod; }
}

int main(){
	ll N, K; cin >> N >> K;
	ll ans = 0, num[K+1];
	for(int g=K; g>=1; g--){
		if(g==K){
			num[K] = 1;
			ans += K;
		}else{
			ll xx = mpow(K/g, N);
			num[g] = xx;
			for(int j=2; j<=(K/g); j++){
				num[g] = (num[g] - num[j*g] + 10*mod) % mod;
			}
			ans = (ans + g*num[g]%mod) % mod;
		}
	}
	cout << ans << endl;
	return 0;
}
