#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define f first
#define s second
 
const int N = 1000*1000 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e16;

ll g[N];

ll pw(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n%2 == 0)
		return pw(((x%mod)*(x%mod))%mod, n/2)%mod;
	return ((pw(((x%mod)*(x%mod))%mod, n/2)%mod) * (x%mod)) % mod;

}


 
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);	
 
 
 	int n, k;
 	cin >> n >> k;
 	ll ans = 0;
 	for(int i = k; i >= 1; i--)
 	{
 		g[i] = pw(k/i, n);
 		for(int j = 2*i; j <= k; j += i)
 		{
 			g[i] += mod;
 			g[i] -= g[j];
 			g[i] %= mod;
 		}
 		
 		ans += ((g[i]%mod)*(i%mod))%mod;
 		ans %= mod;
 	}
 	cout << ans << endl;

	
	
	
	return 0;
}
 
