#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

constexpr int MOD = 1e9 + 7; // 1e9 + 7

#if 1
template<class M, class N>
constexpr common_type_t<M, N> gcd(M m, N n) {

  common_type_t<M, N> a = m, b = n;

  //cout << "gcd(" << a << "," << b << ") = ";

  if (b > a) {
    swap(a, b);
  }

  while (true) {
    common_type_t<M, N> c = a % b;
    if (c == 0) break;

    a = move(b);
    b = move(c);
  }

  //cout << b << '\n';

  return b;
}

template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v% MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};

std::vector<int> sieve(int n) {
  std::vector<int> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (int i = 2; i * i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i * i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return move(res);
}

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

  int N, K;
  cin >> N >> K;

  auto sv = sieve(K + 1);

  // N = 1, K = 12 を [A] とする
  // K
  // 1個 / [A] 1 (12)
  // K/2
  // 割り切れるなら、2^N - 1 個 / [A] 1 (6, 12) - (12)
  // K/3
  // 割り切れるなら、3^N - 1 個 / [A] 2 (4, 8, 12) - (12)
  // K/4
  // 割り切れるなら、4^N - ((2^N - 1) + 1) 個 / [A] 2 (3, 6, 9, 12) - ((6, 12) - (12)) - (12)
  // K/6
  // 6^N - ((

  // F(n) = K/n での個数とする
  // F(n) = n^N - m-G(n)ΣF(m) ただしG(n)はnの素因数分解したとき

  auto ns = vector<Fp<MOD>>(K + 1);
  Fp<MOD> result(0);

  /*
  FOR(i, 1, K + 1) {
    // gcd が K / i である数列の数を求める

    if (K % i != 0) continue; // 割り切れないなら 0個

    Fp<MOD> a = modpow(Fp<MOD>(i), N);
    for (auto j = i; j > 1;) {
      j /= sv[j];
      a -= ns[j];
    }
    //if (i > 1) a -= ns[1];
    ns[i] = a;
    result += a * (K / i);
  }
  */
  RFO(i, 1, K + 1) {
    Fp<MOD> a = modpow(Fp<MOD>(K / i) , N);

    for (auto j = 2; i * j <= K; j++) {
      a -= ns[i * j];
    }
    ns[i] = a;
    result += a * i;
  }

  cout << result.val;

}
#endif

Measured memory_bytes: 4504