#include <bits/stdc++.h>

using namespace std;

const int md = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  auto powr = [&](int base, int power) {
    int res = 1;
    while (power > 0) {
      if (power & 1) {
        res = 1ll * res * base % md;
      }
      base = 1ll * base * base % md;
      power >>= 1;
    }
    return res;
  };
  vector<vector<int>> div(k + 1);
  for (int d = 1; d <= k; d++) {
    for (int j = d + d; j <= k; j += d) {
      div[j].push_back(d);
    }
  }
  vector<int> dp(k + 1);
  int ans = 0;
  for (int g = k; g > 0; g--) {
    (dp[g] += powr(k / g, n)) %= md;
    for (int d : div[g]) {
      (dp[d] += md - dp[g]) %= md;
    }
    (ans += 1ll * g * dp[g] % md) %= md;
  }
  cout << ans << '\n';
  return 0;
}