import std;

const MOD = 10^^9 + 7;

int fac(int n) {
    int res = 1;
    for (int i = 1; i <= n; i++) {
        res = (res * i) % MOD;
    }
    return res;
}

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 a = modPow(k / g, n, MOD);

        long x = a;
        for (int i = g + g; i <= k; i += g) {
            x = (x - memo[i]) % MOD;
            if (x < 0) x += MOD;
        }
        long y = x * g % MOD;
        memo[g] = x;
    }

    long ans = 0;
    foreach (key, val; memo) {
        auto x = key * val % 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;
