// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)

#define rep(i, n) FOR(i, 0, n)

#define whole(x) (x).begin(),(x).end()

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using ll = long long;

using P = pair<int, int>;

const int mod = 1000000007;



struct mint {

    ll x; // typedef long long ll;

    mint(ll x=0):x((x%mod+mod)%mod){}

    mint operator-() const { return mint(-x);}

    mint& operator+=(const mint a) {

        if ((x += a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator-=(const mint a) {

        if ((x += mod-a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator*=(const mint a) {

        (x *= a.x) %= mod;

        return *this;

    }

    mint operator+(const mint a) const {

        mint res(*this);

        return res+=a;

    }

    mint operator-(const mint a) const {

        mint res(*this);

        return res-=a;

    }

    mint operator*(const mint a) const {

        mint res(*this);

        return res*=a;

    }

    mint pow(ll t) const {

        if (!t) return 1;

        mint a = pow(t>>1);

        a *= a;

        if (t&1) a *= *this;

        return a;

    }

    

    // for prime mod

    mint inv() const {

        return pow(mod-2);

    }

    mint& operator/=(const mint a) {

        return (*this) *= a.inv();

    }

    mint operator/(const mint a) const {

        mint res(*this);

        return res/=a;

    }

};



struct combination {

    vector<mint> fact, ifact;

    combination(int n):fact(n+1),ifact(n+1) {

        assert(n < mod);

        fact[0] = 1;

        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;

        ifact[n] = fact[n].inv();

        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;

    }

    mint operator()(int n, int k) {

        if (k < 0 || k > n) return 0;

        return fact[n]*ifact[k]*ifact[n-k];

    }

};





ll gcd(ll a, ll b)

{

    if (b==0) return a;

    return gcd(b, a%b);

}



vector<ll> fac[100005];

ll sumfac[100005];





int main(){

    ll n, k;

    cin >> n >> k;

    //setPrime(k);

    mint ans(0);

    for (ll i=1; i<=k; i++) {

        if (i==1) {

            mint aa(k);

            ans += aa.pow(n);

            continue;

        }

        

        fac[i].push_back(1);

        for (ll j=2; j*j<=i; j++) {

            if (i%j==0) {

                fac[i].push_back(j);

                if (j*j!=i) {

                    fac[i].push_back(i/j);

                }

            }

        }

        ll sum = 0;

        for (ll e:fac[i]) {

            sum += e;

            sum -= sumfac[e];

        }

        sumfac[i] = sum;

        mint x(k/i);

        mint num;

        num = x.pow(n);

        num *= (i-sum);

        ans += num;

        //cout << num.x << endl;

    }



    

    

    

    

    cout << ans.x << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)

#define rep(i, n) FOR(i, 0, n)

#define whole(x) (x).begin(),(x).end()

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using ll = long long;

using P = pair<int, int>;

const int mod = 1000000007;

struct mint {

    ll x; // typedef long long ll;

    mint(ll x=0):x((x%mod+mod)%mod){}

    mint operator-() const { return mint(-x);}

    mint& operator+=(const mint a) {

        if ((x += a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator-=(const mint a) {

        if ((x += mod-a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator*=(const mint a) {

        (x *= a.x) %= mod;

        return *this;

    }

    mint operator+(const mint a) const {

        mint res(*this);

        return res+=a;

    }

    mint operator-(const mint a) const {

        mint res(*this);

        return res-=a;

    }

    mint operator*(const mint a) const {

        mint res(*this);

        return res*=a;

    }

    mint pow(ll t) const {

        if (!t) return 1;

        mint a = pow(t>>1);

        a *= a;

        if (t&1) a *= *this;

        return a;

    }

    

    // for prime mod

    mint inv() const {

        return pow(mod-2);

    }

    mint& operator/=(const mint a) {

        return (*this) *= a.inv();

    }

    mint operator/(const mint a) const {

        mint res(*this);

        return res/=a;

    }

};



mint da[200005];



int main(){

    int n, k;

    cin >> n >> k;

    mint ans(0);



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

        int num = k/i;

        mint now;

        now = mint(num).pow(n);

        

        for (int j=2*i; j<=k; j+=i) {

            now -= da[j];

        }

        da[i] = now;

        now *= i;

        ans += now;

    }

    

    

    

    cout << ans.x << endl;

    return 0;

}


// Fastest known solution for this problem: