#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

ll modmultiply(ll a,ll b,ll c) {
  ll x = 0,y = a%c; 
  while(b > 0) {
    if(b%2 == 1) x = (x+y)%c; 
    y = (y*2)%c;
    b /= 2; 
  }
  return x%c;
}

ll modpow(ll x, ll y, ll mod) {
  ll ret = 1;// ret = x^y%mod;
  while(y) {
    if(y&1)
      //ret = (ret*x)%mod;
      ret = modmultiply(ret, x, mod);
    //x = (x*x)%mod;
    x = modmultiply(x, x, mod);
    y >>= 1;
  }
  return ret;
}

int N,K;

const ll mod = 1000000007LL;

vector<int> getDiv(int n){
  vector<int> res;
  for(int i=1;i*i<=n;i++)
    if(n%i == 0)
	{
	  res.push_back(i);
	  if(i*i != n) 
	    res.push_back(n/i);
	}
  return res;
}


typedef pair<ll,ll> ii;
map<ii,ll> mp;
ll bf_ans = 0;
map<ll,ll> cnt;
void dfs(int cur,ll g,deque<ll> &deq) {
  if( cur >= N ) {
    //cout << "g = " << g << endl;
    cout << "gcd(";
    rep(i,(int)deq.size()) {
      if( i ) cout << ", ";
      cout << deq[i];
    }
    cout << ") = " << g << endl;
    ++cnt[g];
    bf_ans += g;
    bf_ans %= mod;
    return;
  }
  REP(i,1,K+1) {
    deq.pb(i);
    dfs(cur+1,__gcd(g,(ll)i),deq);
    deq.pop_back();
  }
}

ll bf() {
  REP(i,1,K+1) {
    deque<ll> deq;
    deq.pb(i);
    dfs(1,i,deq);
  }
  return bf_ans;
}




ll dp[100010];

void solve() {
  //cout << bf() << endl;
  ll ans = 0;
  for(ll i = K; i >= 1; --i) {
    ll v = K / i;
    dp[i] = modpow(v,N,mod);
    for(ll j=i*2;j<=K;j=j+i) {
      dp[i] -= dp[j];
      while( dp[i] < 0 ) ( dp[i] += mod ) %= mod;
      dp[i] %= mod;
    }
    ( ans += (ll)( i * dp[i] ) ) %= mod ;
  }
  cout << ans << endl;
}

int main() {
  cin >> N >> K;
  solve();
  return 0;
}
