#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}


ll modpow(ll a,ll b){
    ll ret = 1;
    while(b>0){
        if(b&1)ret = (ret*a)%MOD;
        a = (a*a)%MOD;
        b = b>>1;
    }
    return ret;

}

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> nk(n+1,0);
    ll ans = 0;
    for(ll i=k;i>=1;i--){
        ll s = k/i;
        ll gcds = modpow(s,n);
        ll snext = i*2;
        ll next = 3;

        while(snext<=k){
            gcds-=nk[snext];
            if(gcds<0)gcds+=MOD;
            snext=next*i;
            next++;
        }

        ans+=gcds*i;
        ans%=MOD;
        nk[i]=gcds;

    }

    cout<<ans<<endl;






return 0;
}
