//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll power(ll x,ll y){
	ll re=1;
	while(y>0){
		if(y%2)re=re*x%hell;
		x=x*x%hell;
		y=y/2;
	}
	return re;
}
int main(){
	ll n,k;cin>>n>>k;
	ll dp[k+1]={0};
	for(ll i=k;i>=1;i--){
		ll x=k/i;
		dp[i]=power(x,n);
		for(ll j=2*i;j<=k;j+=i){
			dp[i]=(dp[i]-dp[j]+hell)%hell;
		}
	}
	ll sum=0;
	for(ll i=1;i<=k;i++){
		//cout<<dp[i]<<" ";
		sum=(i*dp[i]%hell+sum)%hell;
	}
	cout<<sum<<endl;
}
