

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 endl '\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;
gp_hash_table<int, int> table;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};



int freq;
int n;
int m[N];
int dpx[N];
int fac[N];
int k;

inline int mul(int a, int b) {return (a * 1ll * b) % MOD;}
inline int add(int a, int b) {a += b; if (a >= MOD)a -= MOD; a %= MOD; return a;}
inline int power(int a, int b) {int rt = 1; while (b > 0) {if (b & 1)rt = mul(rt, a); a = mul(a, a); b >>= 1;} return rt;}
inline int inv(int a) {return power(a, MOD - 2);}


int ncr(int n, int r)
{
    if (r > n)return 0;
    int x = fac[n] * inv(fac[n - r]);
    x %= MOD;
    x = x * inv(fac[r]);
    x %= MOD;
    return x;
}

int dp[N];

void check()
{

    rfor(i, n, 1)
    {

        dp[i] = power(dpx[i], k);
        for (int j = 2 * i ; j <= n ; j += i)
        {
            dp[i] = dp[i] - dp[j] + MOD;
            dp[i] %= MOD;
        }
    }
}




void solve()
{
    cin >> k >> n;
    forn(i, 1, n)
    {
        int a;
        a = i;
        m[a]++;
    }
    n = 0;
    forn(i, 0, N - 1)
    {
        n += m[i];
    }
    //cout << n << "\n";
    //dpx[1] = n;

    forn(i, 1, N - 1)
    {
        for (int j = i ; j < N ; j += i)
            dpx[i] += m[j];
    }





    check();

    int ans = 0;
    forn(i, 1, n)
    {
        //cout << dp[i] << " ";
        ans = add(ans, mul(dp[i], i));
    }
    //nl;
    cout << ans;



}


signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin>>t;
    fac[0] = 1;
    forn(i, 1, N - 1)fac[i] = (fac[i - 1] * i) % MOD;
    while (t--)
    {
        solve();
        nl;
    }



    return 0;

}

//       g++ -g c.cpp ; ./a.out
