#include<bits/stdc++.h>

using namespace std;

#define int long long
int mod = 1e9 + 7;
int const maxn = 1e5 + 5;
int dp[maxn];

int st(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) {
        int c = st(x, y / 2);
        return c * c % mod;
    }
    return x * st(x, y - 1) % mod;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = k; i >= 1; --i) {
        int cnt = 1 + (k - i) / i;
        int goal = st(cnt, n);
        for (int j = 2 * i; j <= k; j += i) {
            goal -= dp[j];
            if (goal < 0) goal += mod;
        }
        ans += goal * i;
        ans %= mod;
        dp[i] = goal;
    }
    cout << ans << '\n';
    return 0;
}

