#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const int MX= 1000005;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
 
const int MOD = 1000000007;
using mint = Fp<MOD>;

struct Sieve{
  int n;
  vector<int> f, primes;
  Sieve(int n):n(n),f(n+1){
     f[0]=f[1]=-1;
     for(ll i=2;i<=n;i++){
       if(f[i]){
         continue;
       }
       primes.push_back(i);
       f[i]=i;
       for(ll j=i*i;j<=n;j+=i){
         if(!f[j]) f[j]=i;
       }
     }
  }
  bool isPrime(int x){
    return f[x]==x;
  }
  
  vector<int> factorlist(int x){
    vector<int> res;
    while(x!=1){
      res.push_back(f[x]);
      x/=f[x];
    }
    return res;
  }
  
  vector<P> factor(int x){
    vector<int> fl= factorlist(x);
    if(fl.size()==0){
      return {};
    }
    vector<P> res(1,P(fl[0],0));
    for(int p : fl){
      if(res.back().first==p){
        res.back().second++;
      }
      else{
        res.emplace_back(p,1);
      }
    }
    return res;
  }
};


     


int main(){
  int n,k;cin>>n>>k;
  Sieve p(k+1);
  mint ans;
  ans=0;
  vector<mint> d(k+1);
  rep(i,k){
    int l=i+1;
    d[l]=modpow((mint)(k/l),n);
  }
  for(int u:p.primes){
    for(int i=u;i<=k;i+=u){
      d[i/u]-=d[i];
    }
  }
  for(int i=1;i<=k;i++) ans+=d[i]*i;
  cout<<ans<<endl;
}
  
  