#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()

ll add(ll x, ll y) {
	x += y;
	if(x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if(x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll y) {
	if(y == 0) return 1;
	if(y == 1) return x;
	if(y & 1) return mult(bin_pow(x, y - 1), x);
	return bin_pow(mult(x, x), y / 2);
}

int main(){

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(0); cin.tie(0);
	ll n, k; cin >> n >> k;
	ll ans[k + 1];
	for(int i = 1; i <= k; i++) {
		ans[i] = bin_pow(k / i, n);
	}
	for(int i = k; i >= 1; i--) {
		for(int j = 2 * i; j <= k; j += i) {
			ans[i] = sub(ans[i], ans[j]);
		}
	}
	ll Ans = 0, sum = 0;
	for(int i = 1; i <= k; i++) {
		sum = add(sum, ans[i]);
		Ans = add(Ans, mult(ans[i], i));
	}
	//cout << sum << "\n";
	cout << Ans;
	return 0;
}