#pragma GCC optimize("Ofast")
#include<stdio.h>

int main(){
    unsigned long N, K, ans = 0, v[100001];
    scanf("%lu%lu", &N, &K);
    for(unsigned long i = 1; i <= K; ++i)v[i] = i;
    for(unsigned long i = 2; i <= K; ++i)if(v[i] == i)for(unsigned long j = i; j <= K; j += i)v[j] = (v[j] / i) * (i - 1);
    for(unsigned long i = 1; i <= K; ++i)v[i] = (v[i] + v[i - 1]) % 1000000007;
    for(unsigned long i = K, p = 0; i; ){
        unsigned long t = K / i, r = 1, n = N, a = t;
        while(n){
            if(n & 1){
                r *= a;
                r %= 1000000007;
            }
            a *= a;
            a %= 1000000007;
            n >>= 1;
        }
        ans += (r + p) * v[i];
        i = K / (t + 1);
        p = 1000000007 - r;
    }
    printf("%lu\n", ans % 1000000007);
    return 0;
}