import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    val arr = new Array[BigInt](k)
    for (i <- k to 1 by -1) {
      arr(i - 1) = math.pow(k / i, n).toInt
      
      var m = 2
      while (i * m <= k) {
        arr(i - 1) -= arr(i * m - 1)
        m += 1
      }
    }
    
    val value = for (i <- arr.indices) yield {
      arr(i) * (i + 1)
    }
    
    println(value.sum % 1000000007)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}