#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << (x) << (" ")
#define coutn(x) cout << (x) << ("\n")
#define endl "\n"

template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;


V<int> prime;

map<int,int> prime_factor(int n){
  map<int,int> ret; 
  for(auto x: prime){
    while(n%x==0){
      ++ret[x];
      n /= x;
    }
    if(x*x>n)
    if(n==1) break;
  }
  if(n!=1) ++ret[n];
  return ret;
}

V<int> sieve(int n){
  V<int> ret;
  FOR(i,2,n+1){
    bool isprime = true;
    for(auto x: ret) {
      if(i%x==0){
        isprime = false;
        break;
      }
      if(x*x>i) break;
    }
    if(isprime) ret.push_back(i);
  }
  return ret;
}

ll exgcd(ll a, ll b,ll &x, ll &y){
  ll d = a;
  if(b!=0){
    d = exgcd(b, a%b, y, x);
    y -= (a/b) * x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll modinvex(ll a, ll mod){
  ll x, y;
  exgcd(a,mod,x,y);
  while(x<0){x-=mod*(x/mod - 1);}
  x %= mod;
  return x;
}

ll modpow(ll a, ll b, ll mod){
  ll ans = 1, tmp = a;
  while(b){
    if (b & 1) ans = ans * tmp % mod;
    tmp = tmp * tmp % mod;
    b >>= 1;
  }
  return ans;
}

constexpr ll mod = 1000000007;
void solve(){
  int n, k; cin >> n >> k;
  if(k==1){
    couts(1);
    return;
  }
  ll ans = 0;
  V<ll> xx(k+1,0);
  IFOR(i,1,k+1){
    xx[i] = modpow(k/i,n,mod); //couts(xx[i]);
    FOR(j,2,(k+i+1)/i + 10){
      if(i*j>k) break;
      ((xx[i] -= xx[i*j]) += mod)%=mod;
    }
    (ans += xx[i]*i)%=mod;
  }
  couts(ans);
}


int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 3996