#include <bits/stdc++.h>

using namespace std;

int mod = 1e9 + 7;

int powM(int n, int p) { return (!p ? 1 : (p & 1) ? (1ll * n * powM(n, p - 1)) % mod : powM((1ll * n * n) % mod, p / 2)); }

int add(int a, int b) { return a + b - (a + b >= mod) * mod; }

int sub(int a, int b) { return a - b + (a - b < 0) * mod; }

int mul(int a, int b) { return (1ll * a * b) % mod; }

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

    int n, k;
    cin >> n >> k;
    int g[k + 1] = {}, ans = 0;

    for (int i = k; i >= 1; i--) {
        g[i] = powM(k / i, n);
        for (int j = i + i; j <= k; j += i)
            g[i] = sub(g[i], g[j]);

        ans = add(ans, mul(g[i], i));
    }
    cout << ans << "\n";

    return 0;
}