#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int mod = 1e9 + 7;
vector<ll> x(100100);

ll PowModRepeatSquaring(int a, int p) {
    if (p == 0) return 1;
    if (p % 2 ==0) {
        ll t = PowModRepeatSquaring(a, p / 2);
        return t * t % mod;
    }
    else {
        return a * PowModRepeatSquaring(a, p - 1) % mod;
    }
}

vector<ll> divisor(ll a) {
    vector<ll> res;
    for (ll i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            res.push_back(i);
            if (i * i != a) res.push_back(a / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;

    ll ans = 0;
    for (int i = k; i > 0; --i) {
        ll cnt = ((PowModRepeatSquaring(k / i, n) - x[i]) % mod + mod) % mod;
        ans = (ans + i * cnt) % mod;

        vector<ll> d = divisor(i);
        for (auto &it : d) {
            x[it] = (x[it] + cnt) % mod;
        }
    }

    cout << ans << endl;

    return 0;
}