#include <iostream>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;
//  Table is the complete reverse of dp
//  Always think of the pattern (LCM, GCD)
const int MOD = (int)1e9 + 7;
unsigned long long fast_power(unsigned long long base, unsigned long long power)
{
    unsigned long long result = 1;
    while(power > 0)
    {
        if(power & 1)
        {
            result = ((result % MOD) * (base % MOD)) % MOD;
        }
        base = ((base % MOD) * (base % MOD)) % MOD;
        power >>= 1;
    }
    return result;
}
int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    unsigned long long n, k, ans = 0;
    cin >> n >> k;
    unsigned long long *x = new unsigned long long[k + 1];
    for(unsigned long long i = k; i >= 1; i--)
    {
        unsigned long long tmp = fast_power(k / i, n);
        x[i] = tmp;
        for(int j = 2; i * j <= k; j++)
            x[i] = ((x[i] - x[i * j] + MOD) % MOD + MOD) % MOD;
        ans += (x[i] * i) % MOD;
        ans %= MOD;
    }
    cout << ans;
}