#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

long long addm(long long a, long long b)
{
	return (a + b) % MOD;
}

long long subm(long long a, long long b)
{
	return addm(a, MOD - b);
}

long long mulm(long long a, long long b)
{
	return (a * b) % MOD;
}

long long powm(long long a, long long n)
{
	if (n == 0) {
		return 1;
	}
	else if (n % 2 == 0) {
		return powm(mulm(a, a), n / 2);
	}
	else {
		return mulm(a, powm(mulm(a, a), n / 2));
	}
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long long> dp(K + 1);

	for (int i = K; i >= 1; --i) {
		dp[i] = powm(K / i, N);
		for (int j = 2 * i; j <= K; j += i) {
			dp[i] = subm(dp[i], dp[j]);
		}
	}

	long long ans = 0;
	for (int i = 1; i <= K; ++i) {
		ans = addm(ans, mulm(i, dp[i]));
	}
	cout << ans << endl;
}
