#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

int gcd(ll x, ll y) {
  ll M = max(x, y);
  ll m = min(x, y);
  while (M%m!=0) {
    ll p = M % m;
    M = m;
    m = p;
  }
  return m;
}

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> list(k+1);
  ll sum = 0;
  ll t = 1;
  ll cc = 1;
  ll c = 1;
  for (int i = k; i >0; i--) {
    if (t != k / i) {
      t = k / i;
      cc = r(t, n) % mod;
      c = cc;
    }
    else {
      c = cc;
    }
    ll ii = 2 * i;
    while (ii <= k) {
      c -= list[ii];
      c %= mod;
      ii += i;
    }
    list[i] = c;
    c *= i % mod;
    sum += c;
    sum %= mod;
  }
  if (sum < 0) {
    sum += mod;
  }
  printf("%lld\n", sum);
} 