#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;
//負数の合同も考慮に入れるmod関数
constexpr inline long long imod(const long long a, const long long b)
{
	return (a >= 0) ? (a % b) : (a % b + b);
}

template<long long>class modint;

//modintが引数の繰り返し2乗法
template<long long MOD>
constexpr modint<MOD> m_pow(modint<MOD> x, long long n);

//modの整数クラス
template <long long MOD = 998244353>
class modint
{
public:
	constexpr modint operator+(const modint& other)const
	{
		return modint(a + other.a >= MOD ? a + other.a - MOD : a + other.a, true);
	}
	constexpr modint operator-(const modint& other)const
	{
		return modint(a - other.a < 0 ? a - other.a + MOD : a - other.a, true);
	}
	constexpr modint operator*(const modint& other)const
	{
		return modint(imod(a * other.a, MOD), true);
	}
	constexpr modint operator+=(const modint& other)
	{
		a = a + other.a >= MOD ? a + other.a - MOD : a + other.a;
		//return modint(a, true);
		return *this;
	}
	constexpr modint operator-=(const modint& other)
	{
		a = a - other.a < 0 ? a - other.a + MOD : a - other.a;
		//return modint(a, true);
		return *this;
	}
	constexpr modint operator*=(const modint& other)
	{
		a = imod(a * other.a, MOD);
		//return modint(a, true);
		return *this;
	}
	constexpr modint operator+()const
	{
		return *this;
	}
	constexpr modint operator-()const
	{
		return modint(MOD - a >= MOD ? -a : MOD - a, true);
	}
	constexpr modint& operator++()
	{
		*this += 1;
		return *this;
	}
	constexpr modint operator++(int)
	{
		auto tmp = *this;
		*this += 1;
		return tmp;
	}
	constexpr modint& operator--()
	{
		*this -= 1;
		return *this;
	}
	constexpr modint operator--(int)
	{
		auto tmp = *this;
		*this -= 1;
		return tmp;
	}
	constexpr modint operator~()const
	{
		return m_pow<MOD>(*this, phi - 1);
	}
	constexpr modint& operator=(const modint& other)
	{
		a = other.a;
		return *this;
	}
	constexpr operator long long()const
	{
		return a;
	}
	constexpr explicit operator int()const
	{
		return (int)a;
	}
	constexpr modint(long long a_) :a(imod(a_, mod)) {}
	constexpr modint() : a(0) {}
	static constexpr long long mod = MOD;
private:
	static constexpr long long e_phi() {
		//無効な値は無視
		static_assert(MOD >= 2, "MODの値は2以上にしてください");
		//オイラー関数Φ(mod)を計算する
		long long res = MOD, tmp = MOD;
		for (LL i = 2; i * i <= MOD; ++i)
		{
			if (MOD % i == 0)
			{
				res = res / i * (i - 1);
				for (; tmp % i == 0; tmp /= i);
			}
		}
		if (tmp != 1)res = res / tmp * (tmp - 1);
		return res;
	}
public:
	static constexpr long long phi = modint<MOD>::e_phi();
private:
	//static long long e_phi;
	long long a;
	constexpr modint(long long a_, bool) : a(a_) {}
};



//mintの累乗
//x^nを計算します
template<long long MOD>
constexpr modint<MOD> m_pow(modint<MOD> x, long long n)
{
	modint<MOD> res = 1;
	while (n > 0)
	{
		if (n & 1)res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}



#include<iostream>

//mint型のstreamへの入出力対応
template<long long MOD>
std::ostream& operator<<(std::ostream& os, modint<MOD> i)
{
	os << (long long)i;
	return os;
}

template<long long MOD>
std::istream& operator >> (std::istream& is, modint<MOD>& i)
{
	long long tmp;
	is >> tmp;
	i = tmp;
	return is;
}

//内部で使用する関数
//arrをFFTする
//arr.size() == (1 << logN)
//rootは(1 << logN)乗すると1になる数で、
//roots[i]はrootのi乗(roots.size() == 1 << logN)
template <typename G>
vector<G> FFTraw(vector<G>arr, int logN, const vector<G>& roots) {
	int N = 1 << logN;
	assert(arr.size() == N);
	vector<G>res[2];
	res[0].resize(N);
	res[1].resize(N);
	for (int i = 0; i < N; ++i) {
		int num = 0;
		for (int b = 0; b < logN; ++b) {
			num <<= 1;
			if (i & (1 << b))num++;
		}
		res[0][i] = (arr[num]);
	}
	//for (int i = 0; i < N; ++i)arr[i] = res[i];
	for (LL i = 0; i < logN; ++i) {
		for (int dex = 0; dex < N; ++dex) {
			int mot = dex ^ (1 << i);
			int lef = min(mot, dex);
			int rht = max(mot, dex);
			res[(i + 1) & 1][dex] = res[i & 1][lef] + res[i & 1][rht] * roots[((LL)dex << (logN - i - 1)) % N];
		}
		//for (int i = 0; i < N; ++i)arr[i] = res[i];
	}
	return res[logN & 1];
}

using mint = modint<1000000007>;

int N, K;

mint m_pow(mint a, int x) {
	if (x == 0) {
		return mint(1);
	}
	mint half = m_pow(a, x / 2);
	half *= half;
	if (x % 2) {
		half *= a;
	}
	return half;
}

int main() {
	cin >> N >> K;
	vector<mint>dp(K + 1);
	for (int k = 1; k <= K; ++k) {
		dp[k] = m_pow(K / k, N);
	}
	for (int i = K; i >= 2; i--) {
		for (int j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				dp[j] -= dp[i];
				if (j * j != i && j != 1)dp[i / j] -= dp[i];
			}
		}
	}
	mint ans = 0;
	for (int i = 1; i <= K; ++i) {
		ans += dp[i] * mint(i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4000