#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b)
{
	if(b==1)	return a;
	int res=power(a,b/2);
	res=(res*res)%mod;
	if(b%2)	res=(res*a)%mod;
	return res;
}

void add(int &a,int b)
{
	a=(a+b)%mod;
}

void subtract(int &a,int b)
{
	a=(a-b+mod)%mod;
}

void solve()
{
	int n,i,j,k,x;
	cin>>n>>k;
	int a[k+1],ans=0;
	for(i=k;i>0;i--)
	{
		x=k/i;
		a[i]=power(x,n);
		for(j=2*i;j<=k;j+=i)
			subtract(a[i],a[j]);
		add(ans,(a[i]*i)%mod);
	}
	cout<<ans<<endl;
}
 
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
    	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}