#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

//繰り返し
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

vector< ll > divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

ll n,k;

ll cal(ll x) {  // (K/x)^N
    int p = n;
    x = 1LL * k / x;
    x %= inf;
    ll res = 1;
    while (p > 0) {
        if (p & 1) res = (x * res) % inf;
        x = x * x % inf;
        p >>= 1;
    }
    return res;
}

void esolve(){
    cin >> n >> k;
    ll ans=0;
    ll d[k+1];
    rep(i,k+1) d[i]=0;
    for(ll i=k;i>=1;i--){
        vector<ll> motu=divisor(i);
        ll score=cal(i);
        score%=inf;
        ll extra=0;
        for(ll j=2*i;j<=k;j+=i){
            extra+=d[j];
            extra%=inf;
        }
        d[i]=(score-extra+inf)%inf;
    }
    for(ll i=1;i<=k;i++){
        ans+=i*d[i];
        ans%=inf;
    }
    kaku(ans);
}
int main(){
    esolve();
}