#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}


int main(){
    int n,k;cin >> n >> k;
    vector<ll> memo(k+1,0);
    for(int g=k;g>=1;g--){
        ll s=k/g;
        memo[g]=exp(s,n);
        for(int gg=2*g;gg<=k;gg+=g){
            memo[g]-=memo[gg];
            memo[g]%=big;
        }
    }
    ll ans=0;
    rep(i,k){
        ans+=memo[i+1]*(i+1);
        ans%=big;
    }
    if(ans<0)ans+=big;
    printf("%lld\n",ans);
}