//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    base%=MOD;
    exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base)%MOD;
      base=(1LL*base*base)%MOD;
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     string s;
     cin>>n>>k;
     ll sum=0;
     // sum+=z;
     ll xterms=0;
     ll dp[k+1];
     // cout<<sum<<endl;
     for(i=1;i<=k;i++)
     {
     	ll div=k/i;
     	dp[i]=power(div,n);
     }
     for(i=k;i>=1;i--)
     {
     	for(j=2;j*i<=k;j++)
     	{
     		dp[i]-=dp[j*i];
     		dp[i]+=MOD;
     		dp[i]%=MOD;
     	}
     }
     // ll sum=0;
     for(i=1;i<=k;i++)
     {
     	// cout<<dp[i]<<endl;
     	sum+=(i*dp[i])%MOD;
     	sum%=MOD;
     }
     cout<<sum;

     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}