#include <stdio.h>
#define MOD 1000000007LL

typedef long long ll; 

ll addm(ll a, ll b){
    ll x = (a%MOD+b%MOD)%MOD;
    if (x < 0) x+=MOD;
    return x;
}

ll mulm(ll a, ll b){
    return(a%MOD*b%MOD)%MOD;
}

ll pwm(ll x,ll n){
    x%=MOD;
    ll ans = 1;
    while(n){
        if(n&1) ans=mulm(ans,x);
        x=mulm(x,x);
        n>>=1;
    }
    return ans;
}
 
int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    ll ans=0;
    ll v[K];
    for(int i = K-1;i>=0;i--) {
        v[i] = pwm(K/(i+1),N);
        for(int j = 2*(i+1); j <= K;j+=(i+1)) v[i]=addm(v[i],-v[j-1]);
    }
    for(int i = 0; i<K; i++) ans=addm(ans,mulm(v[i],(addm(i,1LL))));
    printf("%lld\n",ans%MOD);
    return 0;
}