#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;
//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x%num;
    else return ex(x*x%num,n/2)%num;
};
int main(){
    ll n,k;
    cin >> n >> k;
    map<ll,ll> mp;
    //cout << "OK!" << endl;
    for(ll i=2; i<=k; i++){
        mp[i]=(k/i)-(k/(i*i));
    }
    //cout << "OK" << endl;
    cout << mp[2] << endl;
    ll tmp=0;
    ll sum=0;
    for(int i=2; i<=k; i++){
        ll a=ex(mp[i],n)-1;
        sum+=(a*i)%num;
        sum%=num;
        tmp+=mp[i];
        tmp%=num;
    }
    sum+=ex(k,n)-tmp;
    cout << sum << endl;
}