import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val mod = 1000000007L

    val (n, k) = readInputLine().split(" ").map { it.toLong() }

    var ans = 0L

    val cnt = LongArray(k.toInt() + 1)

    for (i in LongRange(1L, k).reversed()) {
        var arrCnt = pow(k / i, n, mod)

        for (j in LongRange(i * 2L, k) step i) {
            arrCnt = (arrCnt - cnt[j.toInt()] + mod) % mod
        }

        cnt[i.toInt()] = arrCnt

        // pw.println("$i $ans")

        ans = (ans + arrCnt * i % mod) % mod
    }

    pw.println(ans)

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}

fun pow(x: Long, n: Long, mod: Long): Long {
    var ret = 1L
    var base = x
    var nTmp = n

    while (nTmp != 0L) {
        if (nTmp % 2L != 0L) {
            ret = ret * base % mod
        }
        base = base * base % mod
        nTmp /= 2L
    }

    return ret
}
