#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    ll N, K;
    cin>>N>>K;
    ll M=1e09+7;
    ll a[K+1];
    ll r;
    for(ll i=K;i>0;i--){
        rep2(j, K/i){
            if(j==1){
                r=K/i;
                rep(k, N-1){
                    r*=K/i;
                    r%=M;
                }
                a[i]=r;
            }
            else{
                a[i]-=a[j*i];
                a[i]=mod(a[i],M);
            }
        }
    }

    ll sum=0;
    rep2(i, K){
        sum+=a[i]*i;
        sum%=M;
    }
    
    cout<<sum<<endl;
}