#include<bits/stdc++.h>

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    unsigned long ans{0};
    for(unsigned long i{1}; i <= K; ++i){
        auto t = K / i;
        auto r{1UL}, n{N}, a{t}, v{i};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        for(unsigned long j{2}, k{i}; j * j <= k || ((k > 1 && ((v /= k) *= (k - 1))), 0); ++j)if(k % j == 0){
            (v /= j) *= (j - 1);
            while(k % j == 0)k /= j;
        }
        ans += r * v;
    }
    cout << ans % MOD << endl;
    return 0;
}