#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

const ll mod=1000000007;

ll modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main(){
    ll n,k;
    cin>>n>>k;
    ll gcd=k;
    ll count=0;
    vll d(k);
    while(gcd>0){
        int c=k/gcd;
        d[gcd]=modPow(c,n,mod);
        count+=d[gcd]*gcd;
        while(c>1){
            count-=d[gcd*c]*gcd;
            c--;
        }
        count%=mod;
        gcd--;
    }
    if(count<0) count+=1000000007;
    cout<<count<<endl;
}
