import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];

    auto dp = new long[](K + 1);
    dp[K] = 1;

    foreach_reverse (i; 1..K) {
        dp[i] = powmod(K / i, N, MOD);
        for (int j = i + i; j <= K; j += i) {
            dp[i] -= dp[j];
            dp[i] = (dp[i] % MOD + MOD) % MOD;
        }
    }

    long ans = 0;
    foreach (i; 1..K+1) (ans += dp[i] * i % MOD) %= MOD;
    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}
