import std;

const MOD = 10^^9 + 7;

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long calc(int n, int k) {
    long[long] memo;
    for (int g = k; g >= 1; g--) {
        long cnt = modPow(k / g, n, MOD);
        for (int i = g + g; i <= k; i += g) {
            cnt -= memo[i];
            if (cnt < 0) cnt += MOD;
        }
        memo[g] = cnt;
    }

    long ans = 0;
    foreach (g, cnt; memo) {
        auto x = g * cnt % MOD;
        ans = (ans + x) % MOD;
    }
    return ans;
}

void main() {
    int n, k; scan(n, k);
    writeln(calc(n, k));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
