#include <vector>
#include <iostream>
using namespace std;
const int M = 1000000007;

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> mu(k+1, 1);
    vector<bool> b(k+1, true);
    for (int p = 2; p <= k; p++) {
        if (b[p]) {
            for (int q = 2*p; q <= k; q += p) b[q] = false;
            for (int q = p; q <= k; q += p) mu[q] *= -1;
            if ((long long)p*p <= k)
                for (int q = p*p; q <= k; q += p*p) mu[q] = 0;
        }
    }
    long long ans = 0;
    for (int a = 1; a <= k; a++)
        for (int b = 1; a*b <= k; b++)
            ans += mu[b] * modexp(k / a / b, n, M) * a % M;
    cout << (ans % M + M) % M << endl;
}
