#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

ll pwr(ll a, ll b){
  ll res = 1;
  while(b > 0){
    if(b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  ll n, k;
  cin >> n >> k;

  vector < ll > gcd(k + 1);
  for(int i = 1; i <= k; i++){
    gcd[i] = pwr(k / i, n);
  }
  for(int i = k; i >= 1; i--){
    for(int j = 2 * i; j <= k; j += i) gcd[i] = (gcd[i] - gcd[j] + mod) % mod;
  }

  ll ans = 0;
  for(int i = 1; i <= k; i++){
    ans = (ans + gcd[i] * i) % mod;
  }

  cout << ans << '\n';
}
