#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  const int mod = 1000 * 1000 * 1000 + 7;

  auto power = [&](int x, int n) {
    int y = 1;
    while (n > 0) {
      if (n & 1) {
        y = (long long)y * x % mod;
      }
      x = (long long)x * x % mod;
      n >>= 1;
    }
    return y;
  };

  int n, k;
  cin >> n >> k;

  vector<int> cnt(k + 1);

  for (int i = k; i > 0; i--) {
    cnt[i] = power(k / i, n);
    for (int j = i + i; j <= k; j += i) {
      cnt[i] -= cnt[j];
      if (cnt[i] < 0) {
        cnt[i] += mod;
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += (long long)i * cnt[i] % mod;
    if (ans >= mod) {
      ans -= mod;
    }
  }

  cout << ans << "\n";
}