#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

ll mod_pow(ll n, ll k, ll p) {
  if (k == 0) return 1;
  ll res = mod_pow(n * n % p, k / 2, p);
  if (k & 1) res = res * n % p;
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(k + 1);
  a[0] = 0;
  rep(i, k) a[i + 1] = mod_pow((ll)i + 1, n, MOD);
  vector<ll> ans(k + 1);
  vector<ll> tmp(k + 1);
  for (ll i = k; i > 0; --i) {
    ll num = k / i;
    tmp[i] = a[num];
    for (ll j = i + i; j <= k; j += i) {
      tmp[i] -= tmp[j];
      while (tmp[i] < 0) tmp[i] += MOD;
    }
    ans[i] = (tmp[i] * i) % MOD;
  }
  ll q = 0;
  rep(i, k) q = (q + ans[i + 1]) % MOD;
  cout << q << endl;
  return 0;
}