#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define pi pair<char,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

const int M = 1e9+7;
int mod(int n){
	n%=M;
	return (n+M)%M;
}

int power(int a,int b){
	int ans=1;
	while(b>0){
		if(b&1)
			ans=mod(ans*a);
		a=mod(a*a);
		b/=2;
	}
	return ans;
}

int32_t main() { 
    boost;
 
	int n,k;
	cin>>n>>k;
	int dp[k+1];
	for(int i=1;i<=k;i++)
		dp[i] = power(k/i,n);
	int ans=0;
	for(int i=k;i>=1;i--){
		for(int j=2*i;j<=k;j+=i){
			dp[i] = mod(dp[i]-dp[j]);
		}
		ans= mod(ans+mod(i*dp[i]));
	}
	cout<<ans<<endl;
}