#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MOD = 1000000007;

ll poww(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b & 1) {
		return (a * poww(a, b - 1)) % MOD;
	}
	return poww((a * a) % MOD, b >> 1);
}

int main() {
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<ll> cnt(k + 1);
	ll ans = 0;
	for (int g = k; g > 0; --g) {
		cnt[g] = poww(k / g, n);
		for (ll j = 2; g * j <= k; ++j) {
			cnt[g] -= cnt[g * j];
			if (cnt[g] < 0) {
				cnt[g] += MOD;
			}
		}
		ans += g * cnt[g];
		ans %= MOD;
	}
	cout << ans << endl;
}