#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll get(ll x, ll y) {
  ll res = 1ll;
  while(y) {
    if(y & 1) {
      res = (res * x) % MOD; 
    }
    y >>= 1;
    x = (x * x) % MOD;
  }
  return res;
}

void solve() {
  int n, k; cin >> n >> k;
  vector <ll> cur(n + 1);
  for(int i = 1; i <= k; i++) {
    cur[i] = get((k / i), n);
  }
  for(int i = k; i >= 1; i--) {
    for(int j = i + i; j <= k; j += i) {
      cur[i] -= cur[j];
      cur[i] %= MOD;
      if(cur[i] < 0) cur[i] += MOD;
    }
  }
  ll ans = 0;
  for(ll i = 1; i <= k; i++) {
    //cout << cur[i] << '\n';
    ans = (ans + i * cur[i]) % MOD;
  }
  cout << ans << '\n';
}

int main() {
  int t; t = 1;
  for(int cs = 1; cs <= t; cs++) {
    solve();
  }
}