
// E - Sum of gcd of Tuples (Hard)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const ll MOD = 1e9 + 7;

ll cnt[100001]; // cnt[i]: GCDがiとなる場合の数

ll mod_pow(ll a, ll n, ll mod) {
	ll result = 1;
	while (n > 0) {
		if (n & 1) result = result * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return result;
}

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

	// GCDがiの倍数となる場合の数（数列のそれぞれの数がiの倍数であればよい）で初期化
	for (int i=1; i<=K; i++) {
		cnt[i] = mod_pow(K/i, N, MOD);
	}

	for (int i=K; i>=1; i--) {
		for (int j=2; i*j<=K; j++) {
			cnt[i] = (cnt[i] - cnt[i*j] + MOD) % MOD;
		}
	}

	ll ans = 0;
	for (int i=1; i<=K; i++) {
		ans = (ans + (cnt[i] * i % MOD)) % MOD;
	}

	cout << ans << endl;

	return 0;
}