// E - Sum of gcd of Tuples (Hard)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

#define MOD 1'000'000'007

// a^n mod m を計算する(繰り返し二乗法,二分累乗法:O(logn))
ll modpow(ll a, ll n) {
	ll m = MOD;
	ll x = 1;
	while(n > 0){
		if(n & 1) x = x * a % m;
		a = a * a % m;
		n >>= 1;
	}
	return x;
}

int main(){
	int N,K; cin>>N>>K;

	vector<ll> cnt_gcd(K+1);

	irp(g, K, 1-1){ // g:[K,1,-1] fixed gcd
		cnt_gcd[g] = modpow(K/g, N); // number of multiples of g
		rp(n, 2, K+1){ // n:[2,K]
			if(n*g > K) break;
			cnt_gcd[g] -= cnt_gcd[n*g];
		}
	}

	ll ans = 0;
	rp(g, 1, K+1) ans = (ans + (cnt_gcd[g] * g % MOD)) % MOD;
	cout<< ans <<endl;
}