#include <stdio.h>
#include <math.h>

long modpow(long a, long n, long mod){
  long size;
  for (long i = 1; ; i++) {
    if (pow(2,i) > n) {
      size = i;
      break;
    }
  }
  long bit[size];
  bit[0] = n;
  for (long i = 1; i < size; i++) {
    bit[i] = bit[i-1]/2;
    bit[i-1] %= 2;
  }
  long powa[size];
  powa[0] = a;
  for (long i = 1; i < size; i++) {
    powa[i] = powa[i-1]*powa[i-1];
    powa[i] %= mod;
  }
  long answer = 1;
  for (long i = 0; i < size; i++) {
    if (bit[i] == 1) {
      answer *= bit[i]*powa[i];
      answer %= mod;
    }
  }
  return answer;
}

int main(void){

  long n,k;
  scanf("%ld %ld", &n, &k);
  long mod = pow(10,9)+7;
  long answer = 0;
  long count[k+1];
  for (long i = k; i >= 1; i--) {
    count[i] = modpow(k/i,n,mod);
    for (long j = 2; i*j <= k; j++) {
      count[i] -= count[i*j];
      count[i] %= mod;
    }
  }
  long sum;
  for (long i = 1; i <= k; i++) {
    sum = i*count[i];
    sum %= mod;
    answer += sum;
    answer %= mod;
  }
  printf("%ld\n", answer);

  return 0;
}