#include <iostream>
#include <vector>
using namespace std;

// a^n (mod) を計算する
int64_t modpow(int64_t a, int64_t n, int64_t mod) {
    int64_t res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int64_t MOD = 1e+09 + 7;

int main(){
    int64_t N,K;
    cin >> N >> K;
    vector<int64_t> num(K+1); // xの倍数の個数はnum(x)
    
    for ( int64_t i = K; i >= 1; --i){
        int64_t count;
        count = modpow( (K/i), N, MOD );
        for ( int64_t j = 2; j <= K; ++j){
            if ( i * j > K ){
                break;
            } else {
                count = count - num.at(i*j);
            }
        }
        num.at(i) = count % MOD;
    }
    int64_t res = 0;
    for ( int i = 1; i <= K; ++i){
        res =  ( res + i * num.at(i) ) % MOD;
    }
    cout << res << endl;
    
    return 0;
}
