fun main() = ABC162E.main()

object ABC162E {
    fun log(message: Any?) {
        //println(message)// TODO: ←消す
    }

    val N: Int
    val K: Int

    init {
        val (n, k) = readInts()
        N = n
        K = k
    }

    data class NumOfTuples(val gcd: Int) : IProblem<Long> {
        override fun getOneChoiceOrNull(): Long? = when {
            K < gcd -> 0
            gcd <= K && K < gcd * 2 -> 1
            else -> null
        }

        override fun hashCode(): Int = gcd
        override fun equals(other: Any?): Boolean {
            if (this === other) return true
            if (javaClass != other?.javaClass) return false

            other as NumOfTuples

            if (gcd != other.gcd) return false

            return true
        }
    }

    fun main() {
        val table = LazyMap<NumOfTuples, ModLong>(capacity = K * 2) { problem ->
            problem.getOneChoiceOrNull()?.toModLong(1000000007) ?: problem.let {
                val all = (K / it.gcd).toModLong(1000000007).pow(N.toLong())
                val ignore = (2 * it.gcd..K step it.gcd).reversed()
                    .map { get(NumOfTuples(it)) }
                    .sum()
                val num = all - ignore
                log("gcd= ${it.gcd} : $num")
                num
            }
        }
        val ans = (1..K).map { X ->
            val count = table[NumOfTuples(gcd = X)]
            val sum = X.toModLong(1000000007) * count
            sum
        }.sum()
        println(ans)
    }

    /*####################################################################################*/

    fun Int.pow(n: Int): Long = Math.pow(this.toDouble(), n.toDouble()).toLong()

    fun readInts() = readLine()!!.split(" ").map { it.toInt() }

    fun Number.toModLong(base: Long): ModLong = ModLong(this.toLong() % base, base)
    class ModLong(
        private val value: Long,
        val base: Long
    ) : Number(), Comparable<ModLong> {
        override fun toString(): String = value.toString()
        override fun equals(other: Any?): Boolean = value == other
        override fun hashCode(): Int = value.hashCode()
        override fun compareTo(other: ModLong): Int = value.compareTo(other.value)
        override fun toByte(): Byte = value.toByte()
        override fun toChar(): Char = value.toChar()
        override fun toDouble(): Double = value.toDouble()
        override fun toFloat(): Float = value.toFloat()
        override fun toInt(): Int = value.toInt()
        override fun toLong(): Long = value
        override fun toShort(): Short = value.toShort()
        operator fun plus(other: ModLong): ModLong = (this.value + other.value).toModLong(base)
        operator fun plus(other: Number): ModLong = (this.value + other.toLong() % base).toModLong(base)
        operator fun minus(other: Number): ModLong = (this.value + base - other.toLong() % base).toModLong(base)
        operator fun times(other: Number): ModLong = (this.value * other.toLong() % base).toModLong(base)
        fun pow(n: Long): ModLong {
            var res = 1L
            var a = value
            var l = n
            while (l > 0) {
                if ((l and 1L) == 1L) {
                    res = (res * a) % base
                }
                a = a * a % base
                l /= 2L
            }
            return res.toModLong(base)
        }
    }

    fun Iterable<ModLong>.sum(): ModLong {
        val base = this.firstOrNull()?.base ?: 1000000007
        return this.fold(0.toModLong(base)) { acc, it -> acc + it }
    }

    class LazyMap<K, V>(capacity: Int = 65536, private val init: LazyMap<K, V>.(K) -> V) {
        private val memo = HashMap<K, V>(capacity)
        operator fun get(key: K): V {
            return memo[key] ?: init(key).memorizingAt(key)
        }

        private fun V.memorizingAt(key: K): V {
            memo[key] = this
            return this
        }
    }

    interface IProblem<T> {
        fun getOneChoiceOrNull(): T?
        override fun equals(other: Any?): Boolean
        override fun hashCode(): Int
    }
}

Measured memory_bytes: 89904