#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<18, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll r[maxn], n, k;
ll bp(ll a, ll p) {
	ll r = 1;
	while(p) {
		if(p&1) r = (r*a)%mod;
		p>>=1, a = a*a%mod;
	}
	return r;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= k; i++) {
		r[i] = bp(k/i, n);
	}
	ll ans = 0;
	for(int i = k; i; i--) {
		for(int j = i+i; j <= k; j+=i)
			r[i] = (mod+r[i]-r[j])%mod;
		ans = (ans + r[i]*i)%mod;
	}
	cout << ans;
	return 0;
}
