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


ll rui( ll a,ll b){
  ll c=1;
 for(;b!=0;b--){
   c*=a;
 };
  return c; 
};  

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