#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)

#define vll    vector<ll>
#define vvll   vector<vector<ll>>
#define all(x) (x).begin(),(x).end()


ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main()
{	
    int N, K;
    cin >> N >> K;

    //counts[i] := iの倍数のN乗の個数 - 「iの倍数の倍数」の個数
    vector<ll> counts(K + 1, 0);

    for (int i = K; i >= 1; i--)
    {
        counts[i] = modpow(K / i, N);

        for (int j = 2 * i; j <= K; j += i)
        {
            counts[i] -= counts[j];
            if (counts[i] < 0) counts[i] += mod;
        }
    }

    ll count = 0;

    reple(i, 1, K)
    {
        count += i * counts[i];
        count %= mod;
    }

    cout << count << endl;

	return 0;
}