#include "bits/stdc++.h"

#define MOD 1000000007LL
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll fact[100100];
ll factinv[100100];

bool setfact(){
  fact[0]=1;
  factinv[0]=1;
  for(int i=1;i<100100;i++){
    fact[i] = mod(i*fact[i-1], MOD);
    factinv[i] = modinv(fact[i], MOD);
  }
}

ll comb(ll n, ll k){
  ll tmp = mod(fact[n]*factinv[k], MOD);
  return mod(tmp * factinv[n-k], MOD);
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  ll num = 0;

  for(ll i=2;i<=K;i++){
    ll tmp = K/i;
    //cout << i << " " << tmp << endl;
    ll a=modpow(tmp, N, MOD);
    ll b=modpow(tmp-1, N, MOD);
    num=mod(num+a,MOD);
    num=mod(num-b,MOD);
    ll a2 = mod(i*a, MOD);
    ll b2 = mod(i*b, MOD);
    ans=mod(ans+a2, MOD);
    ans=mod(ans-b2, MOD);
  }
  ans =mod(ans + modpow(K, N, MOD), MOD);
  ans =mod(ans - num, MOD);
  cout << ans;
  return 0;
}
