#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

int main() {
    ll n, k;
    cin >> n >> k;

    vl w(k+1);
    exrep(x, 1, k) {
        w[x] = modpow(k/x, n);
    }

    vl v(k+1);  // v[x] : GCDがxになる組み合わせの数
    for(ll x = k; x >= 1; x--) {
        ll u = 0;
        for(ll i = 2*x; i <= k; i += x) {
            u += v[i];
            u %= mod;
        }
        v[x] = (w[x] + mod - u)%mod;
    }

    ll ans = 0;
    exrep(x, 1, k) {
        ans += x*v[x];
        ans %= mod;
    }

    out(ans);
    re0;
}