import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val mod = (1e9+7).toLong()

    fun exp(a:Int, b:Int): Long {
        if(b == 0) return 1L
        if(a == 0 || a== 1) return a.toLong()
        var ret = exp(a, b / 2)
        ret *= ret
        ret %= mod
        if(b % 2 == 0) return ret
        ret *= a.toLong()
        ret %= mod
        return ret
    }

    val gcd = LongArray(k + 1)

    for(d in k downTo 1) {
        val v = k / d
        var cnt = exp(v, n)
        var i = 2
        while (d * i <= k) {
            cnt = (cnt - gcd[d * i] + mod) % mod
            ++i
        }
        gcd[d] = cnt
    }
    var ans = 0L
    for(i in 1..k) {
        ans += i * gcd[i]
        ans %= mod
    }
    print(ans)

}