#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

ll power_modulo_fast(ll a, ll b) {    // zwraca (a^b) % MOD
	ll i;
	ll result = 1;
	ll x = a%MOD;

	for (i=1; i<=b; i<<=1) {
		x %= MOD;
		if ((b&i) != 0) {
			result *= x;
			result %= MOD;
		}
		x *= x;
	}

	return result;
}

ll get(ll a, ll b, ll d) {
    ll r = b%d;
    b -= r;
    r = a%d;
    if (r != 0) a += d-r;
    if (a > b) return 0LL;

    return (b-a)/d + 1;
}

ll n, k;
ll s[MAX_N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;
    ll ans = 0LL;

    for (ll i = k; i >= 1; i--) {
        ll cnt = get(1LL, k, i);
        //cout << "D: " << i << " " << cnt << "\n";
        s[i] = power_modulo_fast(cnt, n);
        //cout << i << ": " << s[i] << "\n";
    }

    for (ll i = k; i >= 1; i--) {
        for (ll j = i+i; j <= k; j += i) {
            s[i] -= s[j];
            if (s[i] < 0) s[i] += MOD;
        }
    }

    for (ll i = 1LL; i <= k; i++) {
        ll tmp = (s[i] * i) % MOD;
        ans += tmp;
        ans %= MOD;
    }


    cout << ans;



    return 0;
}
