#include <iostream>
#include <vector>

const long mod = 1000000007l;

int main(){
  long N, K;
  std::cin >> N >> K;
  std::vector<long> sum(K, 0l);
  for(long k = K; k >= 1; --k){
    long el = K/k;
    long num = 1l;
    std::vector<long> bit(64, K/k);
    for(int i = 0; i < 64; ++i){
      for(int j = 0; j < i; ++j){
        bit[i] *= bit[i];
        bit[i] %= mod;
      }
    }
    for(int i = 0; i < 64; ++i){
      if((N >> i) & 1l){
        num *= bit[i];
        num %= mod;
      }
    }
    sum[k-1] = num;
    for(long i = 2; i*k <= K; ++i){
      sum[k-1] -= sum[i*k - 1];
    }
  }
  long count = 0;
  for(long i = 0; i < K; ++i){
    count += sum[i] * (i+1);
    count %= mod;
  }
  std::cout << count << std::endl;
  return 0;
}