#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

ll cnt[100005];
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;
    cnt[k] = 1;
    ll ans = k;
    for(int i = k-1; i >= 1; --i)
    {
        int rp = k/i;
        cnt[i] = pw(rp, n);
        for(int j = i+i; j <= k; j += i)
        {
            cnt[i] = cnt[i] + mod - cnt[j];
            if(cnt[i] >= mod)
                cnt[i] -= mod;
        }
        ans += 1LL * cnt[i] * i;
        ans %= mod;
    }
    cout << ans;
    return 0;
}
