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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

ll cnt[200005];

int qpow(const int&b, const int&e) {
	if(!e) return 1;
	if(!(e&1)) return qpow(1ll*b*b%MOD,e>>1);
	return 1ll*b*qpow(b,e-1)%MOD;
}

int isc[200005];
int primes[200005]; int pc, c;
void sieve(int M) {
	isc[0]=isc[1]=1;
	iter(i, 2, M+1) {
		if(!isc[i]) {
			primes[pc++] = i;
			isc[i] = i;
		}
		if(!(i&1)&&(i<<1)<=M) {
			isc[i<<1] = 2;
			continue;
		}
		for(register int j=0; j<pc; j+=5) {
			if(primes[j] * i > M+1) break;
			isc[primes[j] * i] = primes[j];
			if(!(i % primes[j]) || !primes[j+1] || (primes[j+1] * i > M+1)) break;
			isc[primes[j+1] * i] = primes[j+1];
			if(!(i % primes[j+1]) || !primes[j+2] || (primes[j+2] * i > M+1)) break;
			isc[primes[j+2] * i] = primes[j+2];
			if(!(i % primes[j+2]) || !primes[j+3] || (primes[j+3] * i > M+1)) break;
			isc[primes[j+3] * i] = primes[j+3];
			if(!(i % primes[j+3]) || !primes[j+4] || (primes[j+4] * i > M+1)) break;
			isc[primes[j+4] * i] = primes[j+4];
		}
	}
}

int mu[200005];

void fm() {
	rep1(i, 200005) {
		int j = i, cnt = 0, prev = 0;
		while(j != 1) {
			int v = isc[j];
			if(v == prev) {
				cnt = -1;
				break;
			} else {
				cnt++;
				prev = v;
			}
			j /= v;
		}
		if(cnt == -1) mu[i] = 0;
		else if(cnt%2 == 1) mu[i] = -1;
		else mu[i] = 1;
		mu[i] += mu[i-1];
	}
}

int findcoprime(int n, int k) {
	int ans = 0, r;
	for(int l=1; l<=n; l=r) {
		r = n/(n/l)+1;
		ans = (ans + 1ll*(mu[r-1]-mu[l-1])*qpow(n/l, k)) % MOD;
	}
	return ans;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; gi(k), gi(n);
	sieve(200000);
	fm();
	int ans = 0; ll r;
	for(ll l=1; l<=n; l=r) {
		r = n/(n/l)+1;
		ans = (ans + 1ll * (r*(r-1)/2 - l*(l-1)/2) * findcoprime(n/l, k))%MOD;
	}
	print(ans);
}


Measured memory_bytes: 5312