#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll quickmodpow(ll a,ll b,ll mod){
  ll ans=1%mod;
  while(b){	
    if(b&1) ans=(ans*a)%mod;
    a=(a*a)%mod;
    b=b>>1; 
  }
  return ans;
  }

int main(){
  ll N,K;
  ll mod = 1e9+7;
  cin >> N >> K;
  vector<ll> cnt_gcd(2*K+10,0);
  ll ans = 0;
  cnt_gcd[K] = 1;
  for(ll i=K-1;i>=1;--i){
    cnt_gcd[i] = quickmodpow(ll(K/i),N,mod);
    for(ll j=2*i;j<=K;j=j+i){
      if(cnt_gcd[j]>=1) cnt_gcd[i] = (cnt_gcd[i] - cnt_gcd[j] + mod)%mod;
    }
  }
  for(ll i=1;i<=K;++i){
    ans = (ans + (cnt_gcd[i] * i)) % mod;
  }
  cout << ans << endl;
}