#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

ll power(ll x, ll y) {
	ll a=1;
	while(y){if(y&1)a=a*x%MOD;y>>=1;x=x*x%MOD;}
	return a;
}

int main() {
	int n, k; cin >> n >> k;
	VI s(k+1,0);
	ll ans=0;
	for(int i=k;i>=1;i--){
		int p=k/i;
		s[i]=power(p,n);
		for(int j=2;i*j<=k;j++){
			s[i]-=s[i*j];
			s[i]+=MOD;
			s[i]%=MOD;
		}
		ans+=(s[i]*i)%MOD;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}
