#include<stdio.h>
#define ll long long 
#define mod 1000000007
ll power(ll a, ll b){
    ll x = 1, y = a;
    while(b > 0){
        if(b&1ll)
            x = (x * y) % mod;
        y = (y * y) % mod;
        b >>= 1;
    }
    return x % mod;
}
int main(){
    ll ans = 0, a, n, j, k, i;
    ll dp[555555] = {0};
    scanf("%lld%lld",&n,&k);
    for(i = k; i > 0; i--){
        a = power(k / i, n);
        a %= mod;
        for(j = 2 * i;j <= k; j += i){
            a+= (mod - dp[j]);
            a %= mod;
        }
        ans += a * i;
        ans %= mod;
        dp[i] = a;
    }
    printf("%lld\n",ans);
    return 0;
}