#include<stdio.h>
#include<stdlib.h>
#define  ll long long
#define MOD 1000000007


ll modpow(ll a,ll n)
{
	ll res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % MOD;
		a = a * a % MOD;
		n /= 2;
	}
	return res;
}

#if 0
ll rui( ll a,ll b){
  if(a==1)return 1;
  else {ll c=1;
   for(;b!=0;b--){
     c=c*a%MOD;
   };     
   return c%MOD; 
  };
};  
#endif
int main(){
  ll n,k,d, ans=0;
  scanf("%lld %lld",&n,&k);
  ll  w[k+1];
  for(int a=k;a!=0;a--){
    d=k/a;
    //printf("%lld\n",d);
    w[a]=modpow(d,n);
    for(ll j=2;j*a<=k;j++){
      w[a]-=w[a*j];
    }; 
    if(w[a]>MOD)w[a]%=MOD;
    //printf("%lld ",w[a]);
    ans+=(w[a]*a)%MOD;
  };
  ans%=MOD;
  printf("%lld",ans);
};