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

// a^n mod を計算する
int64_t modpow(int64_t a, int64_t n, int64_t mod) {
    int64_t res = 1;
    while (n > 0) {
        if (n%2 == 1) 
        res = res*a % mod;
        a = a*a % mod;
        n=n/2;
    }
    return res;
}
int main(){
#define rep(i, n) for(int64_t i = 1; i <= (int64_t)(n); i++)
  int64_t N,K;
  long long p;
  int64_t answer=0;
  cin>>N>>K;
  vector<int64_t> r(K+1);
  for(int i=1;i<=K;i++){
    p=K/i;
    r[i]=modpow(p, N, 1000000007 );
  }
  //[K/i]のN乗のリスト
  //i番目にiが乗ってる
  //rep(i,K)
    //cout<<r[i]<<endl;
  for(int i=K;i>=1;i--){
    //if(K>=2){
    for(int j=2;j<=K;j++){
      if(j*i>K)
        break;
      r[i]-=r[j*i];
    }  
  }
  //}
  for(int i=1;i<=K; i++){
    answer+=r[i]*(i)%1000000007;
    answer=answer%1000000007;
  }
  if(answer<0)
    cout<<answer+1000000007;
  else
    cout<<answer;
}