#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
const int siz = 5*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}




signed main()
{
 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int n,k;
		cin>>n>>k;
		int ans[k+1];
		memset(ans,0,sizeof(ans));
		int sum = 0;

		for(int i = k ; i >= 1 ; i--)
		{
			int div = k/i;
			if(div == 0)
			{
				div = 1;
			}
			//cout<<div<<" ";
			ans[i] = be(div,n,mod);

			int sub = 0;

			for(int j = 2*i ; j <= k ; j+= i)
			{
				sub = (sub + ans[j])%mod;
			}

			//cout<<ans[i]<<"\n";

			ans[i] = (ans[i] - sub + mod)%mod;
		}

		for(int i = 1 ; i <= k ; i++)
		{
			int p = i;
			p = (p*ans[i])%mod;
			sum = (sum + p)%mod;
		}

		cout<<sum<<"\n";
	}
}