/*
Idea: maybe try considering which numbers have
d as a divisor:

d, 2*d, 3*d, floor(n/d)*d;




But now suppose we have the tuple
m1*d, m2*d, ..., mk*d,

What if this has an even larger gcd than d?

for instance, its gcd could be 2*d;

So when we consider iteration 2*d, we should 
correct for that. Inclusion-exclusion?

Example, when d = 2, we included tuples (4,4),(4,8),(8,4), (8,8)
so we should subtract 2*(#such tuples);



*/

//returns x^k, mod M

#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>
#include <bitset>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef priority_queue<int, vector<int>, greater<int> > minq;
typedef priority_queue<int> maxq;
// to initialize PQs with a vector, do 
// minq(v.begin(),v.end()) or maxq(v.begin(),v.end())
// or minq(a,a+10) for arrays

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

const long long M = 1000000007;
long long dp[100001];


// returns x^k mod M
ll modpow(int x, int k) {
    ll c = 1, b = (ll)x; int pow = k;
    //c*b^pow = n^k;
    while (pow>0) {
        if (pow%2==0) {
            b*=b;
            b%=M;
            pow/=2;
        } else {
            c*=b;
            c%=M;
            --pow;
        }
    }

    return c;




}


//given 1<=i<=k, returns number of multiples 1*i, 2*i, ..., which are <=k;
int numgoodmultiples(int i, int k) {
    return k/i;
}


    // we want to find the sum of GCDs of all n-tuples 
    //{1,2,...,k} x {1,2,...,k} x ... x {1,2,...,k} (n-fold product)

ll solve(int n, int k) {

    ll ret = 0;

    //dp[i] will denote the NUMBER of tuples
    //in the valid range, who have GCD = i;

    for (int gcd = k; gcd>=1; --gcd) {

        dp[gcd] = modpow(numgoodmultiples(gcd,k),n);

        for (int i = 2; i*gcd <= k; ++i) {
            dp[gcd] += (M - dp[i*gcd]); dp[gcd]%=M;
        }

        ret += (ll)gcd*dp[gcd];
        ret %= M;
    }

     return ret;





}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n,k; cin>>n>>k;

    auto ans = solve(n,k);
    cout<<ans<<el;



    

}
/*
Note to self; right now, say k = 3, n = 4;

Then for the tuple (4,4,4), we would have
already corrected the 1*(4,4,4) factor at step d = 2;

But then at step d = 4, we correcct it again.

So our returned answer is actually too small.



think about tuple n= 6;


At step d = 2, we corrected for tuple (6,6,6)

At step d = 3, we corrected it again.


How do we make sure that if d*tuple is added,
then we only subtract d*tuple once?


We could make sure that any d belongs to only one divisors list?


Similarly, when d = 4, and we consider (4,8,4),
right now we corrected for that from the d=1 and d=2 list.


Similarly, when we do d=6, and consider (6,6,12),
we corrected for that from the d = 1, d=2, AND d=3 list









*/

Measured memory_bytes: 4356