// Slower C++ solution:
/*

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

//#define MOD 998244353

#define INF 1145141919810893364

//#define INF 810114514

//#define PI 3.141592653589

typedef pair<int,int> PP;

typedef long long ll;

#define int ll

#define setdouble setprecision

#define REP(i,n) for(int i=0;i<(n);++i)

#define OREP(i,n) for(int i=1;i<=(n);++i)

#define RREP(i,n) for(int i=(n)-1;i>=0;--i)

#define GOODBYE do { cout << "0" << endl; return 0; } while (false)

#define MM <<" "<<

#define Endl endl

#define debug false



ll pow_mod(ll a,ll b){

  if(b==0){

    return 1;

  }

  else if(b%2==1){

    return (a*pow_mod(a,b-1))%MOD;

  }

  else{

    return (pow_mod(a,b/2)*pow_mod(a,b/2))%MOD;

  }

}



signed main(void){

    int N;

    cin >> N;

    REP(i,N){

        int t = pow_mod(2,MOD-2);

    }

    cout << pow_mod(2,MOD-2);

    return 0;

}

*/





#include <bits/stdc++.h>

using namespace std;

using ll=long long;

const ll MOD=1000000007;

const double PI=3.14159265358979;

const ll INF= pow(10,18);

typedef pair<ll,ll> P;

typedef vector<ll> vl;

typedef vector<vl> vvl;

#define FOR(i,a,b) for(ll i=a;i<b;i++)

string abc="abcdefghijklmnopqrstuvwxyz";

string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";



ll pow_mod(ll a,ll b){

  if(b==0){

    return 1;

  }

  else if(b%2==1){

    return (a*pow_mod(a,b-1))%MOD;

  }

  else{

    ll t=pow_mod(a,b/2);

    return t*t%MOD;

  }

}



vector<ll> memo(200000,-1);

ll cnt_gcd(ll a,ll k,ll n){



  if(memo[a]!=-1){

    return memo[a];

  }

  ll b=pow_mod((k/a),n);

  ll i=1;

  while(a+a*i<=k){

    b =(b-cnt_gcd(a+a*i,k,n))%MOD;

    i++;

  }

  memo[a]=b%MOD;

  return b%MOD;

}

  

int main() {

  ll n,k;

  cin >> n >> k;

  ll ans=0;

  for(ll i=k;i>=1;i--){

    ans=(ans+i*(cnt_gcd(i,k,n)))%MOD;

  }

  cout << (ans+MOD)%MOD << endl;

}






// Faster C++ solution for the same problem (measured speedup: 2.6250153888770265x):
#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

//#define MOD 998244353

#define INF 1145141919810893364

//#define INF 810114514

//#define PI 3.141592653589

typedef pair<int,int> PP;

typedef long long ll;

#define int ll

#define setdouble setprecision

#define REP(i,n) for(int i=0;i<(n);++i)

#define OREP(i,n) for(int i=1;i<=(n);++i)

#define RREP(i,n) for(int i=(n)-1;i>=0;--i)

#define GOODBYE do { cout << "0" << endl; return 0; } while (false)

#define MM <<" "<<

#define Endl endl

#define debug false



int totient(int N){

    if(N<0){

        return 0;

    }

    int R = N;

    for(int i=2;i*i<=N;i++){

        if(N%i==0){

            R -= R/i;

            while(N%i==0){

                N/=i;

            }

        }

    }

    if(N>1){

        R -= R/N;

    }

    return R;

}



std::vector<int> totient_array(int N){

    std::vector<int> R(N+1);

    for(int i=0;i<=N;i++){

        R[i]=i;

    }

    for(int i=2;i<=N;i++){

        if(R[i]!=i)continue;

        for(int j=i;j<=N;j+=i){

            R[j]-=(R[j]/i);

        }

    }

    return R;

}



long long power(long long b,long long e){

    long long r=1;

    while(e){

        if(e&1){

            r=(r*b)%MOD;

        }

        b=(b*b)%MOD;

        e >>=1;

    }

    return r;

}



signed main(void){

    int N,K;

    cin >> N >> K;

    int Ans=0;

    vector<int> tot = totient_array(K);

    for(int i=1;i<=K;i++){

        int b = power(K/i,N);

        int phi = tot[i];

        int r = (b*phi)%MOD;

        //cout << b MM phi MM r << endl;

        Ans=(Ans+r)%MOD;

    }

    cout << Ans << endl;

    

    return 0;

}