#include <bits/stdc++.h>

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

ll N, K;
ll g[200010];

ll powll(ll x){
    vector<ll> v;
    v.push_back(x);
    for(ll i = 1; (1 << i) <= N; i++){
        v.push_back(v[i - 1] * v[i - 1] % MOD);
    }
    ll ret = 1;
    for(ll i = 0; (1 << i) <= N; i++){
        if((1 << i) & N) ret = ret * v[i] % MOD;
    }
    return ret;
}


signed main(){
    cin >> N >> K;
    ll ans = 0;
    for(ll i = K; i > 0; i--){
        g[i] = powll(K / i);
        for(ll j = 2; j * i <= K; j++) g[i] = (g[i] - g[j * i] + MOD) % MOD;
        ans = (ans + g[i] * i) % MOD;
    }
    PRINT(ans);
    return 0;
}