#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
const int MOD=1000000007;

int main(){
  int N,K;
  cin >> N >> K;

  vector<ll> r(K+1,1);

  ll ans=0;
  for(ll i=K;0<i;i--){
    ll t=K/i; t%=MOD;
    for(int j=0;j<20;j++){
      if((N>>j)&1){
	r[i]*=t; r[i]%=MOD;
      }
      t*=t; t%=MOD;
    }
    
    for(int j=2;i*j<=K;j++){
      r[i]-=r[i*j]; r[i]%=MOD;
    }
    ans+=r[i]*i; ans%=MOD;
    //    cout << i << " " << r[i] << endl;
  }

  cout << (ans+MOD)%MOD << endl;
      
  return 0;
}
