//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define pb  push_back
#define mp make_pair
#define ll long long
#define pr pair<int, int> 
#define vpr vector<pr> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define all(n) n.begin(),n.end()
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define Test printf("Case %d: ",tc++);
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
const int mod = (int)1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;


int fastExpo(int a,int b){
	int res = 1;
	a%=mod;
	while(b){
		if(b&1) res = (res*a)%mod;
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}

int sumOfGCD(int n,int k){
	int cnt[k+1] = {0};
	for(int g = k;g>=1;g--){
		int cnt_mul = k/g;
		int tmp;
		tmp = fastExpo(cnt_mul,n);
		tmp%=mod;
		int extra = 0;
		for(int j = g*2;j<=k;j+=g){
			extra = (extra +cnt[j]);
			extra%=mod;
		}

		cnt[g] = (tmp - extra + mod);
		cnt[g] %= mod;
	}
	int sum = 0;
	int add;
	for(int i=1;i<=k;i++){
		add = ((cnt[i]%mod) * (i% mod));
		add %= mod;
		sum += add;
		sum %= mod;
	}

	return sum;
}

int solve() 
{
	//happy coding

	int n,k;
	cin>>n>>k;
	cout<<sumOfGCD(n,k)<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}