#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

//OJ freopen Template
void OJF(const char* inp, const char* out) {
	if (strlen(inp) > 0) freopen(inp, "r", stdin);
	if (strlen(out) > 0) freopen(out, "w", stdout);
}

const int mod = 1e9 + 7, maxn = 100005;

ll binpow(ll a, ll b) {
	int ans = 1, exp = a;
	while(b){
		if(b & 1){
			ans = 1LL * ans * exp % mod;
		}
		exp = 1LL * exp * exp % mod;
		b /= 2;
	}
	return ans;
}

int main(){
    ll n, k;
	cin >> n >> k;
	vector<bool> check(maxn);
	vector<ll> m(maxn), h(maxn);
	for(int i = 1; i <= k; i++){
		m[i] = 1;
		check[i] = true;
	}
	for(int i = 2; i <= k; i++){
		if(check[i]){
			for(int j = i; j <= k; j += i){
				check[j] = false;
				if((j / i) % i == 0){
					m[j] = 0;
				}else{
					m[j] *= -1;
				}
			}
		}
	}
	for(int i = 1; i <= k; i++){
		h[i] = binpow(k / i, n);
	}
	ll ans = 0;
	for(int j = 1; j <= k; j++){
		int f = 0;
		for(int i = j; i <= k; i += j){
			f = (f + 1ll * h[i] * m[i / j]) % mod;
		}
		ans = (ans + 1ll * j * f) % mod;
	}
	cout << (ans + mod) % mod;
	return 0;
}
