/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
ll computeTotient(int n) 
{ 
    // Create and initialize an array to store 
    // phi or totient values 
    long long phi[n+1]; 
    for (int i=1; i<=n; i++) 
        phi[i] = i; // indicates not evaluated yet 
                    // and initializes for product 
                    // formula. 
  
    // Compute other Phi values 
    for (int p=2; p<=n; p++) 
    { 
        // If phi[p] is not computed already, 
        // then number p is prime 
        if (phi[p] == p) 
        { 
            // Phi of a prime number p is 
            // always equal to p-1. 
            phi[p] = p-1; 
  
            // Update phi values of all 
            // multiples of p 
            for (int i = 2*p; i<=n; i += p) 
            { 
               // Add contribution of p to its 
               // multiple i by multiplying with 
               // (1 - 1/p) 
               phi[i] = (phi[i]/p) * (p-1); 
            } 
        } 
    } 
    ll tot = 0;
  
    // Print precomputed phi values 
    for (int i=1; i<=n; i++) tot = add(tot,phi[i]);
    return tot;
} 
void speed_solve(){
    ll n, k;
    cin >> n >> k;
    ll ans = pwr(k,n);
    ll a[k + 1];
    repe(i,2,k + 1){
        a[i] = pwr(k/i,n);
    }
    bace(i,k,2){
        for(ll j = 2 * i ; j <= k ; j+=i){
            ll diff = sub(a[i],a[j]);
            a[i] = diff;
        }
    }
    repe(i,2,k + 1){
        ans = add(ans, mul(a[i], i - 1));
    }
    cout << ans;
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 4432