import java.util.*
import kotlin.math.max

fun main() {
    val jin = Scanner(System.`in`)
    val n = jin.nextInt()
    val q = jin.nextInt()
    val w = jin.nextLong()
    val nodes = Array(n + 1, ::Node)
    nodes[1].parent = nodes[0]
    nodes[1].edges.add(Edge(nodes[0], 0, 0))
    for (i in 0 until n - 1) {
        val a = jin.nextInt()
        val b = jin.nextInt()
        val length = jin.nextLong()
        nodes[a].edges.add(Edge(nodes[b], length, i))
        nodes[b].edges.add(Edge(nodes[a], length, i))
    }
    val dfs = Array(n) { nodes[1] }
    val qodes = Array(n - 1) { nodes[0] }
    var j = 1
    for (i in 0 until n) {
        for (k in 0 until dfs[i].edges.size - 1) {
            var edge = dfs[i].edges[k]
            if (edge.node == dfs[i].parent) {
                edge = dfs[i].edges.last()
                dfs[i].edges[k] = edge
            }
            qodes[edge.ix] = edge.node
            edge.node.parent = dfs[i]
            edge.node.parentLength = edge.length
            dfs[j] = edge.node
            j++
        }
        dfs[i].edges.removeAt(dfs[i].edges.size - 1)
    }
    for (node in dfs.reversed()) {
        node.parent.subTreeSize += node.subTreeSize
        var bestIx = -1
        for (k in 0 until node.edges.size) {
            node.edges[k].node.treeix = k
            if (node.bestChild == null || node.bestChild!!.subTreeSize < node.edges[k].node.subTreeSize) {
                node.bestChild = node.edges[k].node
                bestIx = k
            }
        }
        //println("$node.bestChild = ${node.bestChild}")
        if (node.bestChild != null) {
            node.edges.last().node.treeix = bestIx
            node.edges[bestIx] = node.edges.last()
            node.edges.removeAt(node.edges.size - 1)
        }
        node.hortree = Hortree(node.edges.size)
    }
    for (node in dfs) {
        if (node.parent.bestChild == node) {
            continue
        }
        var amt = 0
        var subNode: Node? = node.bestChild
        while (subNode != null) {
            subNode.treeix = amt
            subNode = subNode.bestChild
            amt++
        }
        node.vertree = Vertree(node, amt)
        subNode = node.bestChild
        while (subNode != null) {
            subNode.vertree = node.vertree
            subNode = subNode.bestChild
        }
    }
    for (node in dfs.reversed()) {
        if (node != nodes[1]) {
            node.update()
        }
    }
    var last: Long = 0
    for (i in 1..q) {
        val d = (jin.nextLong() + last) % (n - 1)
        var e = (jin.nextLong() + last) % w
        var node = qodes[d.toInt()]
        //println("node = $node, e = $e")
        node.parentLength = e
        while (node != nodes[1]) {
            node.update()
            if (node == node.parent.bestChild) {
                node = node.vertree.topNode
            } else {
                node = node.parent
            }
        }
        last = maxOf(nodes[1].hortree.posAnswer(), nodes[1].vertree.posAnswer(), nodes[1].hortree.longest() + nodes[1].vertree.longest())
        println(last)
    }
}

class Node(val ix: Int) {
    lateinit var parent: Node
    var parentLength: Long = -1
    var subTreeSize = 1
    val edges = mutableListOf<Edge>()
    var bestChild: Node? = null
    lateinit var hortree: Hortree
    lateinit var vertree: Vertree
    var treeix = -1

    fun update() {
        //println("$this.update()")
        if (parent.bestChild == this) {
            vertree.update(
                    treeix,
                    Verval(
                            parentLength,
                            hortree.longest() + parentLength,
                            hortree.longest(),
                            hortree.posAnswer()
                    )
            )
        } else {
            parent.hortree.update(
                    treeix,
                    Horval(
                            max(vertree.longest(),
                                    hortree.longest()) + parentLength,
                            0,
                            maxOf(vertree.posAnswer(), hortree.posAnswer(), vertree.longest() + hortree.longest())
                    )
            )
        }
    }

    override fun toString() = "nodes[$ix]"
}

class Edge(val node: Node, val length: Long, val ix: Int)

val HORIZONTAL_IDENTITY = Horval(0, 0, 0)
val VERTICAL_IDENTITY = Verval(0, 0, 0, 0)

data class Horval(val longest1: Long, val longest2: Long, val posAnswer: Long) {
    operator fun plus(other: Horval): Horval {
        if (longest1 > other.longest1) {
            return Horval(longest1, max(longest2, other.longest1), max(posAnswer, other.posAnswer))
        } else {
            return Horval(other.longest1, max(longest1, other.longest2), max(posAnswer, other.posAnswer))
        }
    }
}

data class Verval(val length: Long, val longest: Long, val longestToUse: Long, val posAnswer: Long) {
    // this is above, other is below
    operator fun times(other: Verval) = Verval(
            length + other.length,
            max(longest, other.longest + length),
            max(longestToUse + other.length, other.longestToUse),
            maxOf(posAnswer, other.posAnswer, longestToUse + other.longest)
    )
}

class Hortree(amt: Int) {
    val length: Int
    val array: Array<Horval>

    init {
        var l = 1
        while (l < amt) {
            l *= 2
        }
        length = l
        array = Array(length * 2) { HORIZONTAL_IDENTITY }
    }

    fun update(index: Int, newVal: Horval) {
        var node = index + length
        array[node] = newVal
        node = node shr 1
        while (node > 0) {
            array[node] = array[2 * node] + array[(2 * node) + 1]
            node = node shr 1
        }
    }

    fun longest() = array[1].longest1
    fun posAnswer() = max(array[1].longest1 + array[1].longest2, array[1].posAnswer)
}

class Vertree(val topNode: Node, amt: Int) {
    val length: Int
    val array: Array<Verval>

    init {
        var l = 1
        while (l < amt) {
            l *= 2
        }
        length = l
        array = Array(length * 2) { VERTICAL_IDENTITY }
    }

    fun update(index: Int, newVal: Verval) {
        //println("update($index, $newVal)")
        var node = index + length
        array[node] = newVal
        //println("array[$node] = ${array[node]}")
        node = node shr 1
        while (node > 0) {
            array[node] = array[2 * node] * array[(2 * node) + 1]
            //println("array[$node] = ${array[node]}")
            node = node shr 1
        }
    }

    fun longest() = array[1].longest
    fun posAnswer() = max(array[1].longestToUse, array[1].posAnswer)
}


fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readLong() = readLine()!!.toLong()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)
    fun readLongs() = readLine()!!.split(" ").map(String::toLong)

    readLine()
    val minutes = mutableListOf(0)
    minutes.addAll(readInts())
    minutes.add(90)
    for (pos in 0 until minutes.size - 1)
        if(minutes[pos] + 15 < minutes[pos + 1]) return print(minutes[pos] + 15)
    print(90)
}


import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.math.ln
import kotlin.system.measureTimeMillis

inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}

object IO{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("You forgot to disable tests you digital dummy!")
            println("You forgot to disable tests you digital dummy!")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ IO.OUT.println(aa)}
fun done(){ IO.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){IO.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){IO.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){IO.fakein.append(aa.toString())}
    else{IO.fakein.append(aa.toString())}
    IO.fakein.append("\n")
}

val getint:Int get() = IO.nextInt()
val getlong:Long get() = IO.nextLong()
val getstr:String get() = IO.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
fun getbinary(n:Int):BooleanArray{
    val str = getstr
    return BooleanArray(n){str[it] == '1'}
}

val List<Char>.ret:String
get() = this.joinToString("")
infix fun Any.dei(a:Any){
    //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators
    var str = ""
    if(this is String){ str = this
    }else if(this is Int){ str = this.toString()
    }else if(this is Long){ str = this.toString()
    }
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else{ println("$str : $a")
    }
}
val just = " " // usage: just dei x , where x is the debug variable
fun crash(){throw Exception("Bad programme")} // because assertion does not work
fun assert(a:Boolean){
    if(!a){throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
const val withBruteForce = false
const val randCount = 100
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var answersChecked = 0
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        //safety checks
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Modding a wrong prime!")
        }

        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                IO.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                IO.rerouteInput()
            }
            currentAnswer = null
            currentBruteAnswer = null
            onecase()
        }
        if(withBruteForce){
            put("Checked ${answersChecked}")
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    inline fun brute(a:()->Unit){
        if(withBruteForce){
            a()
        }
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }

    var currentAnswer:String? = null
    var currentBruteAnswer:String? = null
    fun answer(a:Any){
        currentAnswer = a.toString()
        if(currentBruteAnswer != null){
            checkAnswer()
        }
    }
    fun put2(a:Any){answer(a);put(a) }

    fun bruteAnswer(a:Any){
        currentBruteAnswer = a.toString()
        if(currentAnswer != null){
            checkAnswer()
        }
    }
    fun checkAnswer(){
        if(currentAnswer != currentBruteAnswer){
            throw Exception("Failed Test: BF $currentBruteAnswer Current $currentAnswer")
        }
        answersChecked ++
    }
}
// 1. Modded
const val p = 998244353L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this * 1L * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()

infix fun Int.divCeil(b:Int):Int{
    //Positives numbers only!
    if(this == 0) {
        return 0
    }
    return (this-1)/b + 1
}
infix fun Long.divCeil(b:Long):Long{
    //Positives numbers only!
    if(this == 0L) {
        return 0
    }
    return (this-1)/b + 1
}

infix fun Long.modM(b:Long):Long{
    return (this * b) % p
}
//infix fun Int.modPlus(b:Int):Int{
//    val ans = this + b
//    return if(ans >= pI) ans - pI else ans
//}
infix fun Int.modMinus(b:Int):Int{
    val ans = this - b
    return if(ans < 0) ans + pI else ans
}
infix fun Int.modDivide(b:Int):Int{
    return this modM (b.inverse())
}
fun Int.additiveInverse():Int{
    return if(this == 0) 0 else pI - this
}

fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x
    var E =e
    var Y = 1
    while(E > 0){
        if(E % 2 == 0){
            X = ((1L * X * X) % m).toInt()
            E /= 2
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}

fun pow(x:Long,e:Long,m:Long):Long{
    var X = x
    var E =e
    var Y = 1L
    while(E > 0){
        if(E % 2 == 0L){
            X = (X * X) % m
            E /= 2
        }else{
            Y = (X * Y) % m
            E -= 1
        }
    }
    return Y
}
fun Long.inverse():Long{
    return pow(this,p-2,p)
}
fun Int.inverse():Int{
    return intPow(this,pI-2,pI)
}
//make this int instead
class FACT{
    companion object {
        var store = IntArray(0)
        var invStore = IntArray(0)

        var slowStore:IntArray = IntArray(0)

        fun preCal(upto:Int){
            store = IntArray(upto+1)
            invStore = IntArray(upto + 1 )
            store[0] = 1
            invStore[0] = 1

            for(i in 1..upto) {
                store[i] = store[i-1] modM i
                invStore[i] = invStore[i-1] modM (i.inverse())
            }
        }
        fun choose(n:Int,r:Int):Int{
            if(r < 0 || r > n) return 0
            val a = store[n]
            val b = invStore[n-r]
            val c = invStore[r]
            return (a modM b) modM c
        }

        fun bigChoose(n:Int,r:Int):Int{
            var ret = 1
            for(i in 0 until r){
                ret = ret modM (n - i)
            }
            ret = ret modM (invStore[r])
            return ret
        }

    }
}

class FFT {
    companion object{
        //        val fftmod = 7340033
//        val root = 5
//        val root_1 = 4404020
//        val root_pw = 1 shl 20
        private const val fftmod = 998244353
        private const val root = 15311432
        private const val root_1 = 469870224
        private const val root_pw = 1 shl 23

        fun calculateRoot(){
            println("root :$root")
            //   intPow(3,7 * 17,fftmod)
            println("root_1 : $root_1")
            //       intPow(root,fftmod -2,fftmod)
        }

        fun fft(a:IntArray,invert:Boolean){
            val n = a.size
            var j = 0

            for(i in 1 until n){
                var bit = n shr 1
                while(j and bit > 0){
                    j = j xor bit
                    bit = bit shr 1
                }
                j = j xor bit
                if(i < j){
                    val temp = a[i]
                    a[i] = a[j]
                    a[j] = temp
                }
            }
            var len = 2
            while(len <= n){
                var wlen = if(invert) root_1 else root
                var i = len
                while(i < root_pw){
                    wlen = (1L * wlen * wlen % fftmod).toInt()
                    i = i shl 1
                }
                i = 0
                while(i < n){
                    var w = 1
                    for(j in 0 until len/2){
                        val u = a[i+j]
                        val v = (1L * a[i+j+len/2] * w % fftmod).toInt()
                        a[i+j] = if(u+v < fftmod) u + v else u + v - fftmod
                        a[i+j+len/2] = if(u-v >= 0) u-v else u-v+fftmod
                        w = (1L * w * wlen % fftmod).toInt()
                    }
                    i += len
                }
                len = len shl 1
            }
            if(invert){
                val n_1 = pow(n.toLong(),(fftmod-2).toLong(),fftmod.toLong())
                for((i,x) in a.withIndex()){
                    a[i] = (1L * x * n_1 % fftmod).toInt()
                }
            }
        }
        fun fullconvolution(at:IntArray,bt:IntArray):IntArray{
            return fullconvolutionOpt(at,bt,at.size,bt.size)
        }

        fun fullconvolutionOpt(at:IntArray,bt:IntArray,sizeA:Int,sizeB:Int):IntArray{
            // 1 shl 18 done in 77 ms
            val maxSize = (sizeA + sizeB).takeHighestOneBit() * 2
            val a = at.copyOf(maxSize)
            val b = bt.copyOf(maxSize)
            val expectedSize = at.size + bt.size - 1
            fft(a,false)
            fft(b,false)
            val new = IntArray(maxSize)
            for(i in new.indices){
                new[i] = (1L * a[i] * b[i] % fftmod).toInt()
            }
            fft(new,true)
            return new.copyOf(expectedSize)
        }
    }
}

fun stir(l:Int, r:Int):IntArray{
    if(l == r){
        return intArrayOf(l,1)
    }else{
        val mid = (l+r) shr 1
        return FFT.fullconvolution(stir(l,mid), stir(mid+1,r))
    }
}

object sieve{

    const val sieveMx = 200005
    val primeOf = IntArray(sieveMx + 1)
    var primeCounter = 0
    val primeUpperBound = maxOf(25,(sieveMx.toDouble()/(ln(sieveMx.toDouble()) -4)).toInt() +3)
    val primes = IntArray(primeUpperBound)
    var sieveCalculated = false
    val nextPrime = IntArray(sieveMx+1)
    val nextPrimePower = IntArray(sieveMx+1)
    val afterPrimePowerDivison = IntArray(sieveMx+1)
    var mobius = IntArray(0)

    var factors:List<MutableList<Int>> = mutableListOf()

    fun calculateSieveFast(){
        if(sieveCalculated){
            return
        }
        sieveCalculated = true
        for(i in 2..sieveMx){
            if(primeOf[i] == 0 ){
                primeOf[i] = i
                primes[primeCounter] = i
                primeCounter += 1
            }
            for(j in 0 until primeCounter){
                val p = primes[j]
                val pd = p * i
                if(p <= i && pd <= sieveMx){
                    primeOf[pd] = p
                }else{
                    break
                }
            }
        }
    }
    fun preparePrimePower(){
        nextPrime[1] = -1
        nextPrimePower[1] = -1
        afterPrimePowerDivison[1] = 1
        for(i in 2..sieveMx){
            val p = primeOf[i]
            val new = i / p
            nextPrime[i] = p
            if(nextPrime[new] == p){
                nextPrimePower[i] = nextPrimePower[new]
                afterPrimePowerDivison[i] = afterPrimePowerDivison[new]
            }else{
                afterPrimePowerDivison[i] = new
            }
            nextPrimePower[i] += 1
        }
    }
    fun prepareFactors(){
        // 700ms in 1M
        // shoudl not be used for 1M
        // 200ms codeforces for 200k
        factors = List(sieveMx + 1){ mutableListOf()}
        factors[1].add(1)

        for(i in 2..sieveMx){
            val p = nextPrime[i]
            val a = nextPrimePower[i]
            val old = afterPrimePowerDivison[i]

            var here = 1
            repeat(a+1){
                for(c in factors[old]){
                    factors[i].add(c * here )
                }
                here *= p
            }
//            factors[1].ad
//            factors[i].addAll(i.factors())
        }
    }
    fun calculateMobius(){
        kotlin.assert(sieveCalculated)
        mobius = IntArray(sieveMx + 1)
        mobius[1] = 1
        for(i in 2..sieveMx){
            val p = primeOf[i]
            if(p == primeOf[i/p]){
                mobius[i] = 0
            }else{
                mobius[i] = -1 * mobius[i/p]
            }
        }
    }
}
inline fun Int.eachPrimePower(act:(Int,Int)->Unit){
    var here = this
    while(here > 1){
        act(sieve.nextPrime[here], sieve.nextPrimePower[here])
        here = sieve.afterPrimePowerDivison[here]
    }
}
fun GS(start:Int,ratio:Int,count:Int) = sequence {
    var ret = 1
    for(i in 1
            ..count){
        ret *= ratio
        yield(ret)
    }
}
fun Int.factors():List<Int>{
    val ret = mutableListOf(1)
    this.eachPrimePower { p, e ->
        val s = ret.toList()
        for(pn in GS(p,p,e)){
            ret.addAll(s.map{it * pn})
        }
    }
    return ret
}
fun totient(a:Int):Int{
    var ret = a
    a.eachPrimePower{
            p, _ ->
        ret /= p
        ret *= (p-1)
    }
    return ret
}
fun Int.numOfDivisors():Int{
    var ret = 1
    this.eachPrimePower { _, e -> ret *= (e+1) }
    return ret
}
fun Int.factorLook():List<Int>{
    return sieve.factors[this]
}

fun stirtry2(n:Int):IntArray {
    val A = IntArray(n+1){
        val x = FACT.invStore[it]
        if(it %2 == 0) x else x.additiveInverse()
    }
    val B = IntArray(n+1){
        intPow(it, n,pI) modM FACT.invStore[it]
    }
    val F = FFT.fullconvolution(A,B)

    return F
}
val recitations = mutableMapOf<Int,Int>()
fun getitdone(n:Int, k:Int):Int{
    if(recitations[n] != null){
        return recitations[n]!!
    }
    val that = stirtry2(n)
    var ret = 0
    for(i in 1..minOf(n,k)){
        ret = ret modPlus that[i]
    }
//    "$n $k " dei thatv\\

    val final = ret modMinus 1
    recitations[n] = final
    return final
}

var n =0
const val singleCase = true
fun main(){
    FACT.preCal(200005)
    sieve.calculateSieveFast()
    sieve.calculateMobius()

//    just dei stirtry2(6)
    solve.cases{
        n = getint
        val k = getint
        var ans = 0

        if(k == 1 || n ==1){
            put(1)
            return@cases

        }

        for(i in 1..n){
            val m = sieve.mobius[i].adjust()
            if(m == 0) continue

            val now = getitdone(n divCeil i,k)
//            i dei now
            ans = ans modPlus ( now modM m)
        }
        put(ans)
    }
    done()
}
/*
just number of such patterns

n
n/2
n/3

 */


import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.math.ln
import kotlin.system.measureTimeMillis

inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}

object IO{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("You forgot to disable tests you digital dummy!")
            println("You forgot to disable tests you digital dummy!")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ IO.OUT.println(aa)}
fun done(){ IO.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){IO.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){IO.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){IO.fakein.append(aa.toString())}
    else{IO.fakein.append(aa.toString())}
    IO.fakein.append("\n")
}

val getint:Int get() = IO.nextInt()
val getlong:Long get() = IO.nextLong()
val getstr:String get() = IO.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
fun getbinary(n:Int):BooleanArray{
    val str = getstr
    return BooleanArray(n){str[it] == '1'}
}

val List<Char>.ret:String
get() = this.joinToString("")
infix fun Any.dei(a:Any){
    //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators
    var str = ""
    if(this is String){ str = this
    }else if(this is Int){ str = this.toString()
    }else if(this is Long){ str = this.toString()
    }
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else{ println("$str : $a")
    }
}
val just = " " // usage: just dei x , where x is the debug variable
fun crash(){throw Exception("Bad programme")} // because assertion does not work
fun assert(a:Boolean){
    if(!a){throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
const val withBruteForce = false
const val randCount = 100
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var answersChecked = 0
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        //safety checks
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Modding a wrong prime!")
        }

        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                IO.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                IO.rerouteInput()
            }
            currentAnswer = null
            currentBruteAnswer = null
            onecase()
        }
        if(withBruteForce){
            put("Checked ${answersChecked}")
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    inline fun brute(a:()->Unit){
        if(withBruteForce){
            a()
        }
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }

    var currentAnswer:String? = null
    var currentBruteAnswer:String? = null
    fun answer(a:Any){
        currentAnswer = a.toString()
        if(currentBruteAnswer != null){
            checkAnswer()
        }
    }
    fun put2(a:Any){answer(a);put(a) }

    fun bruteAnswer(a:Any){
        currentBruteAnswer = a.toString()
        if(currentAnswer != null){
            checkAnswer()
        }
    }
    fun checkAnswer(){
        if(currentAnswer != currentBruteAnswer){
            throw Exception("Failed Test: BF $currentBruteAnswer Current $currentAnswer")
        }
        answersChecked ++
    }
}
// 1. Modded
const val p = 998244353L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this * 1L * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()

infix fun Int.divCeil(b:Int):Int{
    //Positives numbers only!
    if(this == 0) {
        return 0
    }
    return (this-1)/b + 1
}
infix fun Long.divCeil(b:Long):Long{
    //Positives numbers only!
    if(this == 0L) {
        return 0
    }
    return (this-1)/b + 1
}

infix fun Long.modM(b:Long):Long{
    return (this * b) % p
}
//infix fun Int.modPlus(b:Int):Int{
//    val ans = this + b
//    return if(ans >= pI) ans - pI else ans
//}
infix fun Int.modMinus(b:Int):Int{
    val ans = this - b
    return if(ans < 0) ans + pI else ans
}
infix fun Int.modDivide(b:Int):Int{
    return this modM (b.inverse())
}
fun Int.additiveInverse():Int{
    return if(this == 0) 0 else pI - this
}

fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x
    var E =e
    var Y = 1
    while(E > 0){
        if(E % 2 == 0){
            X = ((1L * X * X) % m).toInt()
            E /= 2
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}

fun pow(x:Long,e:Long,m:Long):Long{
    var X = x
    var E =e
    var Y = 1L
    while(E > 0){
        if(E % 2 == 0L){
            X = (X * X) % m
            E /= 2
        }else{
            Y = (X * Y) % m
            E -= 1
        }
    }
    return Y
}
fun Long.inverse():Long{
    return pow(this,p-2,p)
}
fun Int.inverse():Int{
    return intPow(this,pI-2,pI)
}
//make this int instead
class FACT{
    companion object {
        var store = IntArray(0)
        var invStore = IntArray(0)

        var slowStore:IntArray = IntArray(0)

        fun preCal(upto:Int){
            store = IntArray(upto+1)
            invStore = IntArray(upto + 1 )
            store[0] = 1
            invStore[0] = 1

            for(i in 1..upto) {
                store[i] = store[i-1] modM i
                invStore[i] = invStore[i-1] modM (i.inverse())
            }
        }
        fun choose(n:Int,r:Int):Int{
            if(r < 0 || r > n) return 0
            val a = store[n]
            val b = invStore[n-r]
            val c = invStore[r]
            return (a modM b) modM c
        }

        fun bigChoose(n:Int,r:Int):Int{
            var ret = 1
            for(i in 0 until r){
                ret = ret modM (n - i)
            }
            ret = ret modM (invStore[r])
            return ret
        }

    }
}

class FFT {
    companion object{
        //        val fftmod = 7340033
//        val root = 5
//        val root_1 = 4404020
//        val root_pw = 1 shl 20
        private const val fftmod = 998244353
        private const val root = 15311432
        private const val root_1 = 469870224
        private const val root_pw = 1 shl 23

        fun calculateRoot(){
            println("root :$root")
            //   intPow(3,7 * 17,fftmod)
            println("root_1 : $root_1")
            //       intPow(root,fftmod -2,fftmod)
        }

        fun fft(a:IntArray,invert:Boolean){
            val n = a.size
            var j = 0

            for(i in 1 until n){
                var bit = n shr 1
                while(j and bit > 0){
                    j = j xor bit
                    bit = bit shr 1
                }
                j = j xor bit
                if(i < j){
                    val temp = a[i]
                    a[i] = a[j]
                    a[j] = temp
                }
            }
            var len = 2
            while(len <= n){
                var wlen = if(invert) root_1 else root
                var i = len
                while(i < root_pw){
                    wlen = (1L * wlen * wlen % fftmod).toInt()
                    i = i shl 1
                }
                i = 0
                while(i < n){
                    var w = 1
                    for(j in 0 until len/2){
                        val u = a[i+j]
                        val v = (1L * a[i+j+len/2] * w % fftmod).toInt()
                        a[i+j] = if(u+v < fftmod) u + v else u + v - fftmod
                        a[i+j+len/2] = if(u-v >= 0) u-v else u-v+fftmod
                        w = (1L * w * wlen % fftmod).toInt()
                    }
                    i += len
                }
                len = len shl 1
            }
            if(invert){
                val n_1 = pow(n.toLong(),(fftmod-2).toLong(),fftmod.toLong())
                for((i,x) in a.withIndex()){
                    a[i] = (1L * x * n_1 % fftmod).toInt()
                }
            }
        }
        fun fullconvolution(at:IntArray,bt:IntArray):IntArray{
            return fullconvolutionOpt(at,bt,at.size,bt.size)
        }

        fun fullconvolutionOpt(at:IntArray,bt:IntArray,sizeA:Int,sizeB:Int):IntArray{
            // 1 shl 18 done in 77 ms
            val maxSize = (sizeA + sizeB).takeHighestOneBit() * 2
            val a = at.copyOf(maxSize)
            val b = bt.copyOf(maxSize)
            val expectedSize = at.size + bt.size - 1
            fft(a,false)
            fft(b,false)
            val new = IntArray(maxSize)
            for(i in new.indices){
                new[i] = (1L * a[i] * b[i] % fftmod).toInt()
            }
            fft(new,true)
            return new.copyOf(expectedSize)
        }
    }
}

fun stir(l:Int, r:Int):IntArray{
    if(l == r){
        return intArrayOf(l,1)
    }else{
        val mid = (l+r) shr 1
        return FFT.fullconvolution(stir(l,mid), stir(mid+1,r))
    }
}

object sieve{

    const val sieveMx = 200005
    val primeOf = IntArray(sieveMx + 1)
    var primeCounter = 0
    val primeUpperBound = maxOf(25,(sieveMx.toDouble()/(ln(sieveMx.toDouble()) -4)).toInt() +3)
    val primes = IntArray(primeUpperBound)
    var sieveCalculated = false
    val nextPrime = IntArray(sieveMx+1)
    val nextPrimePower = IntArray(sieveMx+1)
    val afterPrimePowerDivison = IntArray(sieveMx+1)
    var mobius = IntArray(0)

    var factors:List<MutableList<Int>> = mutableListOf()

    fun calculateSieveFast(){
        if(sieveCalculated){
            return
        }
        sieveCalculated = true
        for(i in 2..sieveMx){
            if(primeOf[i] == 0 ){
                primeOf[i] = i
                primes[primeCounter] = i
                primeCounter += 1
            }
            for(j in 0 until primeCounter){
                val p = primes[j]
                val pd = p * i
                if(p <= i && pd <= sieveMx){
                    primeOf[pd] = p
                }else{
                    break
                }
            }
        }
    }
    fun preparePrimePower(){
        nextPrime[1] = -1
        nextPrimePower[1] = -1
        afterPrimePowerDivison[1] = 1
        for(i in 2..sieveMx){
            val p = primeOf[i]
            val new = i / p
            nextPrime[i] = p
            if(nextPrime[new] == p){
                nextPrimePower[i] = nextPrimePower[new]
                afterPrimePowerDivison[i] = afterPrimePowerDivison[new]
            }else{
                afterPrimePowerDivison[i] = new
            }
            nextPrimePower[i] += 1
        }
    }
    fun prepareFactors(){
        // 700ms in 1M
        // shoudl not be used for 1M
        // 200ms codeforces for 200k
        factors = List(sieveMx + 1){ mutableListOf()}
        factors[1].add(1)

        for(i in 2..sieveMx){
            val p = nextPrime[i]
            val a = nextPrimePower[i]
            val old = afterPrimePowerDivison[i]

            var here = 1
            repeat(a+1){
                for(c in factors[old]){
                    factors[i].add(c * here )
                }
                here *= p
            }
//            factors[1].ad
//            factors[i].addAll(i.factors())
        }
    }
    fun calculateMobius(){
        kotlin.assert(sieveCalculated)
        mobius = IntArray(sieveMx + 1)
        mobius[1] = 1
        for(i in 2..sieveMx){
            val p = primeOf[i]
            if(p == primeOf[i/p]){
                mobius[i] = 0
            }else{
                mobius[i] = -1 * mobius[i/p]
            }
        }
    }
}
inline fun Int.eachPrimePower(act:(Int,Int)->Unit){
    var here = this
    while(here > 1){
        act(sieve.nextPrime[here], sieve.nextPrimePower[here])
        here = sieve.afterPrimePowerDivison[here]
    }
}
fun GS(start:Int,ratio:Int,count:Int) = sequence {
    var ret = 1
    for(i in 1
            ..count){
        ret *= ratio
        yield(ret)
    }
}
fun Int.factors():List<Int>{
    val ret = mutableListOf(1)
    this.eachPrimePower { p, e ->
        val s = ret.toList()
        for(pn in GS(p,p,e)){
            ret.addAll(s.map{it * pn})
        }
    }
    return ret
}
fun totient(a:Int):Int{
    var ret = a
    a.eachPrimePower{
            p, _ ->
        ret /= p
        ret *= (p-1)
    }
    return ret
}
fun Int.numOfDivisors():Int{
    var ret = 1
    this.eachPrimePower { _, e -> ret *= (e+1) }
    return ret
}
fun Int.factorLook():List<Int>{
    return sieve.factors[this]
}

fun stirlingNumbers(n:Int):IntArray {
    val A = IntArray(n+1){
        val x = FACT.invStore[it]
        if(it %2 == 0) x else x.additiveInverse()
    }
    val B = IntArray(n+1){
        intPow(it, n,pI) modM FACT.invStore[it]
    }
    val F = FFT.fullconvolution(A,B)

    return F
}
val recitations = mutableMapOf<Int,Int>()
fun getitdone(n:Int, k:Int):Int{
    if(recitations[n] != null){
        return recitations[n]!!
    }
    val that = stirlingNumbers(n)
    var ret = 0
    for(i in 1..minOf(n,k)){
        ret = ret modPlus that[i]
    }
//    "$n $k " dei thatv\\

    val final = ret modMinus 1
    recitations[n] = final
    return final
}

var n =0
const val singleCase = true
fun main(){
    FACT.preCal(200005)
    sieve.calculateSieveFast()
    sieve.calculateMobius()

//    just dei stirtry2(6)
    solve.cases{
        n = getint
        val k = getint
        var ans = 0

        if(k == 1 || n ==1){
            put(1)
            return@cases

        }

        for(i in 1..n){
            val m = sieve.mobius[i].adjust()
            if(m == 0) continue

            val now = getitdone(n divCeil i,k)
//            i dei now
            ans = ans modPlus ( now modM m)
        }
        put(ans)
    }
    done()
}
/*
just number of such patterns

n
n/2
n/3

 */


import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.math.ln
import kotlin.system.measureTimeMillis

inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}

object IO{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("You forgot to disable tests you digital dummy!")
            println("You forgot to disable tests you digital dummy!")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ IO.OUT.println(aa)}
fun done(){ IO.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){IO.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){IO.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){IO.fakein.append(aa.toString())}
    else{IO.fakein.append(aa.toString())}
    IO.fakein.append("\n")
}

val getint:Int get() = IO.nextInt()
val getlong:Long get() = IO.nextLong()
val getstr:String get() = IO.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
fun getbinary(n:Int):BooleanArray{
    val str = getstr
    return BooleanArray(n){str[it] == '1'}
}

val List<Char>.ret:String
get() = this.joinToString("")
infix fun Any.dei(a:Any){
    //does not stand for anything it is just easy to type, have to be infix because kotlin does not have custom prefix operators
    var str = ""
    if(this is String){ str = this
    }else if(this is Int){ str = this.toString()
    }else if(this is Long){ str = this.toString()
    }
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else{ println("$str : $a")
    }
}
val just = " " // usage: just dei x , where x is the debug variable
fun crash(){throw Exception("Bad programme")} // because assertion does not work
fun assert(a:Boolean){
    if(!a){throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
const val withBruteForce = false
const val randCount = 100
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var answersChecked = 0
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        //safety checks
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Modding a wrong prime!")
        }

        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                IO.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                IO.rerouteInput()
            }
            currentAnswer = null
            currentBruteAnswer = null
            onecase()
        }
        if(withBruteForce){
            put("Checked ${answersChecked}")
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    inline fun brute(a:()->Unit){
        if(withBruteForce){
            a()
        }
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }

    var currentAnswer:String? = null
    var currentBruteAnswer:String? = null
    fun answer(a:Any){
        currentAnswer = a.toString()
        if(currentBruteAnswer != null){
            checkAnswer()
        }
    }
    fun put2(a:Any){answer(a);put(a) }

    fun bruteAnswer(a:Any){
        currentBruteAnswer = a.toString()
        if(currentAnswer != null){
            checkAnswer()
        }
    }
    fun checkAnswer(){
        if(currentAnswer != currentBruteAnswer){
            throw Exception("Failed Test: BF $currentBruteAnswer Current $currentAnswer")
        }
        answersChecked ++
    }
}
// 1. Modded
const val p = 998244353L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this * 1L * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()

infix fun Int.divCeil(b:Int):Int{
    //Positives numbers only!
    if(this == 0) {
        return 0
    }
    return (this-1)/b + 1
}
infix fun Long.divCeil(b:Long):Long{
    //Positives numbers only!
    if(this == 0L) {
        return 0
    }
    return (this-1)/b + 1
}

infix fun Long.modM(b:Long):Long{
    return (this * b) % p
}
//infix fun Int.modPlus(b:Int):Int{
//    val ans = this + b
//    return if(ans >= pI) ans - pI else ans
//}
infix fun Int.modMinus(b:Int):Int{
    val ans = this - b
    return if(ans < 0) ans + pI else ans
}
infix fun Int.modDivide(b:Int):Int{
    return this modM (b.inverse())
}
fun Int.additiveInverse():Int{
    return if(this == 0) 0 else pI - this
}

fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x
    var E =e
    var Y = 1
    while(E > 0){
        if(E % 2 == 0){
            X = ((1L * X * X) % m).toInt()
            E /= 2
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}

fun pow(x:Long,e:Long,m:Long):Long{
    var X = x
    var E =e
    var Y = 1L
    while(E > 0){
        if(E % 2 == 0L){
            X = (X * X) % m
            E /= 2
        }else{
            Y = (X * Y) % m
            E -= 1
        }
    }
    return Y
}
fun Long.inverse():Long{
    return pow(this,p-2,p)
}
fun Int.inverse():Int{
    return intPow(this,pI-2,pI)
}
//make this int instead
class FACT{
    companion object {
        var store = IntArray(0)
        var invStore = IntArray(0)

        var slowStore:IntArray = IntArray(0)

        fun preCal(upto:Int){
            store = IntArray(upto+1)
            invStore = IntArray(upto + 1 )
            store[0] = 1
            invStore[0] = 1

            for(i in 1..upto) {
                store[i] = store[i-1] modM i
                invStore[i] = invStore[i-1] modM (i.inverse())
            }
        }
        fun choose(n:Int,r:Int):Int{
            if(r < 0 || r > n) return 0
            val a = store[n]
            val b = invStore[n-r]
            val c = invStore[r]
            return (a modM b) modM c
        }

        fun bigChoose(n:Int,r:Int):Int{
            var ret = 1
            for(i in 0 until r){
                ret = ret modM (n - i)
            }
            ret = ret modM (invStore[r])
            return ret
        }

    }
}

class FFT {
    companion object{
        //        val fftmod = 7340033
//        val root = 5
//        val root_1 = 4404020
//        val root_pw = 1 shl 20
        private const val fftmod = 998244353
        private const val root = 15311432
        private const val root_1 = 469870224
        private const val root_pw = 1 shl 23

        fun calculateRoot(){
            println("root :$root")
            //   intPow(3,7 * 17,fftmod)
            println("root_1 : $root_1")
            //       intPow(root,fftmod -2,fftmod)
        }

        fun fft(a:IntArray,invert:Boolean){
            val n = a.size
            var j = 0

            for(i in 1 until n){
                var bit = n shr 1
                while(j and bit > 0){
                    j = j xor bit
                    bit = bit shr 1
                }
                j = j xor bit
                if(i < j){
                    val temp = a[i]
                    a[i] = a[j]
                    a[j] = temp
                }
            }
            var len = 2
            while(len <= n){
                var wlen = if(invert) root_1 else root
                var i = len
                while(i < root_pw){
                    wlen = (1L * wlen * wlen % fftmod).toInt()
                    i = i shl 1
                }
                i = 0
                while(i < n){
                    var w = 1
                    for(j in 0 until len/2){
                        val u = a[i+j]
                        val v = (1L * a[i+j+len/2] * w % fftmod).toInt()
                        a[i+j] = if(u+v < fftmod) u + v else u + v - fftmod
                        a[i+j+len/2] = if(u-v >= 0) u-v else u-v+fftmod
                        w = (1L * w * wlen % fftmod).toInt()
                    }
                    i += len
                }
                len = len shl 1
            }
            if(invert){
                val n_1 = pow(n.toLong(),(fftmod-2).toLong(),fftmod.toLong())
                for((i,x) in a.withIndex()){
                    a[i] = (1L * x * n_1 % fftmod).toInt()
                }
            }
        }
        fun fullconvolution(at:IntArray,bt:IntArray):IntArray{
            return fullconvolutionOpt(at,bt,at.size,bt.size)
        }

        fun fullconvolutionOpt(at:IntArray,bt:IntArray,sizeA:Int,sizeB:Int):IntArray{
            // 1 shl 18 done in 77 ms
            val maxSize = (sizeA + sizeB).takeHighestOneBit() * 2
            val a = at.copyOf(maxSize)
            val b = bt.copyOf(maxSize)
            val expectedSize = at.size + bt.size - 1
            fft(a,false)
            fft(b,false)
            val new = IntArray(maxSize)
            for(i in new.indices){
                new[i] = (1L * a[i] * b[i] % fftmod).toInt()
            }
            fft(new,true)
            return new.copyOf(expectedSize)
        }
    }
}

fun stir(l:Int, r:Int):IntArray{
    if(l == r){
        return intArrayOf(l,1)
    }else{
        val mid = (l+r) shr 1
        return FFT.fullconvolution(stir(l,mid), stir(mid+1,r))
    }
}

object sieve{

    const val sieveMx = 200005
    val primeOf = IntArray(sieveMx + 1)
    var primeCounter = 0
    val primeUpperBound = maxOf(25,(sieveMx.toDouble()/(ln(sieveMx.toDouble()) -4)).toInt() +3)
    val primes = IntArray(primeUpperBound)
    var sieveCalculated = false
    val nextPrime = IntArray(sieveMx+1)
    val nextPrimePower = IntArray(sieveMx+1)
    val afterPrimePowerDivison = IntArray(sieveMx+1)
    var mobius = IntArray(0)

    var factors:List<MutableList<Int>> = mutableListOf()

    fun calculateSieveFast(){
        if(sieveCalculated){
            return
        }
        sieveCalculated = true
        for(i in 2..sieveMx){
            if(primeOf[i] == 0 ){
                primeOf[i] = i
                primes[primeCounter] = i
                primeCounter += 1
            }
            for(j in 0 until primeCounter){
                val p = primes[j]
                val pd = p * i
                if(p <= i && pd <= sieveMx){
                    primeOf[pd] = p
                }else{
                    break
                }
            }
        }
    }
    fun preparePrimePower(){
        nextPrime[1] = -1
        nextPrimePower[1] = -1
        afterPrimePowerDivison[1] = 1
        for(i in 2..sieveMx){
            val p = primeOf[i]
            val new = i / p
            nextPrime[i] = p
            if(nextPrime[new] == p){
                nextPrimePower[i] = nextPrimePower[new]
                afterPrimePowerDivison[i] = afterPrimePowerDivison[new]
            }else{
                afterPrimePowerDivison[i] = new
            }
            nextPrimePower[i] += 1
        }
    }
    fun prepareFactors(){
        // 700ms in 1M
        // shoudl not be used for 1M
        // 200ms codeforces for 200k
        factors = List(sieveMx + 1){ mutableListOf()}
        factors[1].add(1)

        for(i in 2..sieveMx){
            val p = nextPrime[i]
            val a = nextPrimePower[i]
            val old = afterPrimePowerDivison[i]

            var here = 1
            repeat(a+1){
                for(c in factors[old]){
                    factors[i].add(c * here )
                }
                here *= p
            }
//            factors[1].ad
//            factors[i].addAll(i.factors())
        }
    }
    fun calculateMobius(){
        kotlin.assert(sieveCalculated)
        mobius = IntArray(sieveMx + 1)
        mobius[1] = 1
        for(i in 2..sieveMx){
            val p = primeOf[i]
            if(p == primeOf[i/p]){
                mobius[i] = 0
            }else{
                mobius[i] = -1 * mobius[i/p]
            }
        }
    }
}
inline fun Int.eachPrimePower(act:(Int,Int)->Unit){
    var here = this
    while(here > 1){
        act(sieve.nextPrime[here], sieve.nextPrimePower[here])
        here = sieve.afterPrimePowerDivison[here]
    }
}
fun GS(start:Int,ratio:Int,count:Int) = sequence {
    var ret = 1
    for(i in 1
            ..count){
        ret *= ratio
        yield(ret)
    }
}
fun Int.factors():List<Int>{
    val ret = mutableListOf(1)
    this.eachPrimePower { p, e ->
        val s = ret.toList()
        for(pn in GS(p,p,e)){
            ret.addAll(s.map{it * pn})
        }
    }
    return ret
}
fun totient(a:Int):Int{
    var ret = a
    a.eachPrimePower{
            p, _ ->
        ret /= p
        ret *= (p-1)
    }
    return ret
}
fun Int.numOfDivisors():Int{
    var ret = 1
    this.eachPrimePower { _, e -> ret *= (e+1) }
    return ret
}
fun Int.factorLook():List<Int>{
    return sieve.factors[this]
}

fun stirtry2(n:Int):IntArray {
    val A = IntArray(n+1){
        val x = FACT.invStore[it]
        if(it %2 == 0) x else x.additiveInverse()
    }
    val B = IntArray(n+1){
        intPow(it, n,pI) modM FACT.invStore[it]
    }
    val F = FFT.fullconvolution(A,B)

    return F
}
val recitations = mutableMapOf<Int,Int>()
fun getitdone(n:Int, k:Int):Int{
    if(recitations[n] != null){
        return recitations[n]!!
    }
    val that = stirtry2(n)
    var ret = 0
    for(i in 1..minOf(n,k)){
        ret = ret modPlus that[i]
    }
//    "$n $k " dei thatv\\

    val final = ret modMinus 1
    recitations[n] = final
    return final
}

var n =0
const val singleCase = true
fun main(){
    FACT.preCal(200005)
    sieve.calculateSieveFast()
    sieve.calculateMobius()

//    just dei stirtry2(6)
    solve.cases{
        n = getint
        val k = getint
        var ans = 0

        if(n == 1 && k == 1){
            put(1)
            return@cases
        }

        for(i in 1..n){
            val m = sieve.mobius[i].adjust()
            if(m == 0) continue

            val now = getitdone(n divCeil i,k)
//            i dei now
            ans = ans modPlus ( now modM m)
        }
        put(ans)
    }
    done()
}
/*
just number of such patterns

n
n/2
n/3

 */


import java.io.*
import java.util.*

fun DataReader.solve(out: PrintWriter) {
    val s = nextToken()

    out.println((0..s.length - 1).mapTo(mutableSetOf()) { s.substring(it) + s.substring(0, it) }.size)
}

fun Boolean.toYesNo() = if (this) "YES" else "NO"

class DataReader(private val reader: BufferedReader) {
    var st : StringTokenizer? = null
    companion object {
        fun createFromFile(name: String) = DataReader(BufferedReader(FileReader(name)))
    }

    fun next() : String? {
        while (st == null || !st!!.hasMoreTokens()) {
            val s = reader.readLine() ?: return null
            st = StringTokenizer(s)
        }

        return st?.nextToken()
    }

    fun nextToken() = next()!!

    fun nextInt() = nextToken().toInt()
    fun nextLong() = nextToken().toLong()
    fun readIntArray(n: Int) : IntArray {
        val result = IntArray(n)
        result.indices.forEach { i -> result[i] = nextInt() }
        return result
    }

    fun nextLine() = reader.readLine()
}

fun main(args: Array<String>) {
    val r: Reader
    val out: PrintWriter
    if (System.getProperty("ONLINE_JUDGE") == null) {
        r = FileReader("input.txt")
        out = PrintWriter("output.txt")
    } else {
        r = InputStreamReader(System.`in`)
        out = PrintWriter(System.out)
    }

    DataReader(BufferedReader(r)).solve(out)
    out.flush()
}


fun main(args: Array<String>) {
    val str = readLine()!!

    val a = Array(str.length) { "" }
    a[0] = str
    for (i in 1..str.length - 1) {
        a[i] = a[i - 1].substring(1) + a[i - 1][0]
    }

    val ans = a.toSet().size
    println(ans)
}


fun main() {
    val s = readLine()!!
    val words = mutableSetOf<String>()
    for (start in s.indices)
        words.add(s.substring(start, s.length) + s.substring(0, start))
    print(words.size)
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

data class Player(val a: Int, val d: Int)

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val P = Array(4){Player(ni(), ni())}
    fun play(x1: Int) = run{
      (0 until 2).map { x2 ->
        val a1 = P[x1].a
        val d1 = P[1 xor x1].d
        val a2 = P[2 + x2].a
        val d2 = P[2 + (1 xor x2)].d

        if (a1 > d2 && d1 > a2) 0
        else if (a2 > d1 && d2 > a1) 2
        else 1
      }.max()!!
    }

    val res = min(play(0), play(1))
    val ans = when(res) {
      0 -> "Team 1"
      1 -> "Draw"
      2 -> "Team 2"
      else -> ""
    }
    out.println(ans)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl()
    }
    return res
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


import kotlin.math.absoluteValue
import kotlin.math.max

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (x1, y1) = readInts()
    val (x2, y2) = readInts()
    print((max(2, (x1 - x2).absoluteValue + 1)) * 2 + max(2, ((y1 - y2).absoluteValue + 1)) * 2)
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val A = ni()
    val B = ni()
    if (B > A) {
      out.println(0)
      return
    }

    if (A == B) {
      out.println("infinity")
      return
    }

    val mx = (A - B)
    var x = 1
    var ans = 0
    while(x * x <= mx) {
      if (mx % x == 0) {
        if (A % x == B) ans++
        if (x * x != mx && A % (mx / x) == B) ans++
      }
      x++
    }
    out.println(ans)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n, offset) { ni() }
  }

  private inline fun map(n: Int, offset: Int = 0, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i + offset)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun <A, B> pair(a: A, b: B) = RPair(a, b)
data class RPair<A, B>(val _1: A, val _2: B)

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


import kotlin.math.max
import kotlin.math.min

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (vStart, vEnd) = readInts()
    val (time, d) = readInts()
    var meters = 0
    var currentTime = 0
    var currentSpeed = vStart
    while(currentTime < time) {
        meters += currentSpeed
        currentTime++
        val timeAfter = time - currentTime - 1
        val desiredSpeed = vEnd + timeAfter*d
        currentSpeed = max(currentSpeed - d, min(desiredSpeed, currentSpeed + d))
    }
    print(meters)
}


fun main() {
    val n = readLine()!!.toInt()
    var output = false
    for (a in 0..n / 1234567) {
        for (b in 0..(n - a * 1234567) / 123456) {
            for (c in 0..(n - a * 1234567 - b * 123456) / 1234) {
                if (a * 1234567 + b * 123456 + c * 1234 == n) {
                    output = true
                    break
                }
            }
            if(output) break
        }
        if (output) break
    }
    if (output) print("YES") else print("NO")
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val dp = Array(N + 1){Array(2){LongArray(N + 10)} }
    dp[0][0][0] = 1

    for (i in 0 until N) {
      for (j in 0 .. N) {
        for (s in 0 until 2) { // reflexiveを満たさない
          for (k in 0 until 2) { // 追加するか
            for (l in 0 until 2) { // 連結するか
              if (k == 0 && l == 1) continue
              val nj = if (k == 1 && l == 0) j + 1 else j
              val ns = if (s == 0 && k == 1) 0 else 1
              val c = if (l == 1) j else 1
              dp[i + 1][ns][nj] = (dp[i + 1][ns][nj] + dp[i][s][j] * c) % MOD
            }
          }
        }
      }
    }

    debug(dp[N][0])
    debug(dp[N][1])

    out.println(dp[N][1].sum() % MOD)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

private val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val dp = Array(N + 1){Array(2){LongArray(N + 10)} }
    dp[0][0][0] = 1

    for (i in 0 until N) {
      for (j in 0 .. N) {
        for (s in 0 until 2) { // reflexiveを満たさない
          for (k in 0 until 2) { // 追加するか
            for (l in 0 until 2) { // 連結するか
              if (k == 0 && l == 1) continue
              val nj = if (k == 1 && l == 0) j + 1 else j
              val ns = if (s == 0 && k == 1) 0 else 1
              val c = if (l == 1) j else 1
              dp[i + 1][ns][nj] = (dp[i + 1][ns][nj] + dp[i][s][j] * c) % MOD
            }
          }
        }
      }
    }

    debug(dp[N][0])
    debug(dp[N][1])

    out.println(dp[N][1].sum() % MOD)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

private val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    var best = Array(2){LongArray(N + 10)}
    var next = Array(2){LongArray(N + 10)}
    best[0][0] = 1

    for (i in 0 until N) {
      Arrays.fill(next[0], 0)
      Arrays.fill(next[1], 0)
      for (j in 0 .. i) {
        for (s in 0 until 2) { // reflexiveを満たさない
          for (k in 0 until 2) { // 追加するか
            for (l in 0 until 2) { // 連結するか
              if (k == 0 && l == 1) continue
              val nj = if (k == 1 && l == 0) j + 1 else j
              val ns = if (s == 0 && k == 1) 0 else 1
              val c = if (l == 1) j else 1
              next[ns][nj] = (next[ns][nj] + best[s][j] * c) % MOD
            }
          }
        }
      }
      val tmp = best
      best = next
      next = tmp
    }

    debug(best[0])
    debug(best[1])

    out.println(best[1].sum() % MOD)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


import java.io.File

fun main(args: Array<String>) {
    /*
    val lines = File("actual").readText().split("\n").filter { ' ' in it }
    val correct = lines.map { s -> s.substringAfter(" ") }
    val ns = lines.map { s -> s.substringBefore(" ").toInt() }
    var wrong = 0
    */

    repeat(readLine()!!.toInt()) { test ->
        val a = readLine()!!.split(' ').map(String::toInt).toIntArray()

        val min = a.min()!!
        val max = a.max()!!
        val u = (Math.abs(min) + Math.abs(max)) / 2

        val v = a.sumByDouble { x -> x * x * 1.0 } / a.size
        val sv = Math.sqrt(v)

        val ans = if (2*sv > u && (u > 5 || (min >= -u && max <= u))) "uniform" else "poisson"
        println(ans)

        /*
        if (ans != correct[test]) {
            println("$test min=$min max=$max u=$u v=$v sv=$sv expected=${correct[test]} actual=$ans N=${ns[test]}")
            wrong++
        }
        */
    }

    // println("correct ${correct.size - wrong} wrong $wrong")
}


import java.util.*

fun main(args: Array<String>) {
    with(Scanner(System.`in`)) {
        val n = nextLong()
        val m = nextLong()
        val k = nextLong()
        val r = k % (m * n)
        if (r < n) {
            println("${r+1} 1")
        } else {
            val r0 = r - n
            val t0 = r0 / (m-1)
            val t1 = r0 % (m-1)
            if (t0 % 2 == 0L) {
                println("${n-t0} ${1+t1}")
            } else {
                println("${n-t0} ${1+m-1-t1}")
            }
        }
    }
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.min

fun main(args: Array<String>)
        = Thread { run() }.start()

fun run() {

    val scanner = Scanner(System.`in`)
    val n = scanner.nextLong()
    val m = scanner.nextLong()
    var q = scanner.nextLong()
    if (q < n) {
        println("${q + 1} 1")
        return
    }
    q -= n;
    val r = n - (q / (m - 1))
    if ((n - r) % 2 == 0L)
        println("$r ${2 + (q % (m - 1))}")
    else
        println("$r ${m - (q % (m - 1))}")
}

class Scanner(s: InputStream) {
    var st: StringTokenizer? = null
    var br: BufferedReader = BufferedReader(InputStreamReader(s))
    @Throws(IOException::class)
    operator fun next(): String {
        while (st == null || !st!!.hasMoreTokens())
            st = StringTokenizer(br.readLine())
        return st!!.nextToken()
    }
    @Throws(IOException::class)
    fun nextInt(): Int {
        return Integer.parseInt(next())
    }
    @Throws(IOException::class)
    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }
    @Throws(IOException::class)
    fun nextLine(): String {
        return br.readLine()
    }
    @Throws(IOException::class)
    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }
    @Throws(IOException::class)
    fun ready(): Boolean {
        return br.ready()
    }
}
class Pair(var a: Int, var b: Int): Comparable<Pair> {
    override fun compareTo(other: Pair): Int {
        return a - other.a
    }
}


import java.io.*
import java.text.SimpleDateFormat
import java.util.*
import kotlin.Comparator
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.math.round
import kotlin.random.Random
import kotlin.system.measureTimeMillis

/**
 * 23.02.2020
 * Main
 *
 * @author Havlong
 * @version v1.0
 */
class LineReader(tempReader: Reader) {
    private val reader = BufferedReader(tempReader)
    fun hasNext() = peek() != -1
    private fun peek(): Int {
        reader.mark(1)
        return reader.read().also { reader.reset() }
    }

    fun skipSpaces() {
        while (Character.isWhitespace(peek()))
            reader.read()
    }

    fun readLine(): String = reader.readLine()
    fun longList() = readLine().split(' ').map(String::toLong)
    fun intList() = readLine().split(' ').map(String::toInt)
}

typealias ML = MutableList<Long>
typealias MI = MutableList<Int>
typealias LL = List<Long>
typealias LLL = List<LL>
typealias PLL = Pair<Long, Long>
typealias PPLL = Pair<Long, PLL>

const val M7 = 1000000007L
const val M9 = 1000000009L
const val MFFT = 998244353L
const val INF = 2000000000000000000L

fun lowerBound(from: Long, to: Long, comparison: (Long) -> Long): Long {
    var left = from
    var right = to + 1
    while (left < right) {
        val mid = (left + right) / 2
        val result = comparison(mid)
        if (result >= 0) {
            right = mid
        } else {
            left = mid + 1
        }
    }
    return left
}

fun upperBound(from: Long, to: Long, comparison: (Long) -> Long): Long {
    var left = from
    var right = to + 1
    while (left < right) {
        val mid = (left + right) / 2
        val result = comparison(mid)
        if (result > 0) {
            right = mid
        } else {
            left = mid + 1
        }
    }
    return left
}

fun <T : Comparable<T>> List<T>.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> List<T>.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> Array<T>.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> Array<T>.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

operator fun <A : Comparable<A>, B : Comparable<B>> Pair<A, B>.compareTo(other: Pair<A, B>): Int {
    return first.compareTo(other.first).let { if (it == 0) second.compareTo(other.second) else it }
}

fun binPow(number: Long, power: Long, mod: Long): Long {
    var result = 1L
    var a = number % mod
    var n = power
    while (n > 0) {
        if (n % 2 != 0L)
            result = (result * a) % mod
        a = (a * a) % mod
        n /= 2
    }
    return result
}

tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = a * b / gcd(a, b)

fun main(args: Array<String>) {
    if (args.isNotEmpty() && args[0] == "local") {
        val reader = LineReader(FileReader("input.txt"))
        PrintWriter(File("output.txt")).use {
            while (reader.hasNext()) {
                it.println("\n${measureTimeMillis {
                    solve(reader, it)
                }} ms\n")
                reader.skipSpaces()
            }
        }
    } else {
        val reader = LineReader(InputStreamReader(System.`in`))
        PrintWriter(System.out).use { solve(reader, it) }
    }
}

fun solve(reader: LineReader, writer: PrintWriter) {
    val format = SimpleDateFormat("yyyy:MM:dd")
    val start = format.parse(reader.readLine().trim())
    val end = format.parse(reader.readLine().trim())
    writer.println(abs(round((end.time - start.time) / 1000.0 / 3600 / 24)).toLong())
}


fun main() {
    val s = readLine()!!
    val t = readLine()!!
    if (s.length < t.length) {
        print("need tree")
        return
    }
    val longMap = IntArray(26)
    for (c in s) longMap[c - 'a']++
    for (c in t) {
        if (longMap[c - 'a'] > 0) longMap[c - 'a']-- else {
            print("need tree")
            return
        }
    }
    val automaton = s.length != t.length
    var sPos = 0
    var lPos = 0
    while (sPos < t.length && lPos < s.length) {
        if (t[sPos] == s[lPos]) sPos++
        lPos++
    }
    print(
        when {
            automaton && sPos < t.length -> "both"
            automaton -> "automaton"
            else -> "array"
        }
    )
}


fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readLong() = readLine()!!.toLong()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)
    fun readLongs() = readLine()!!.split(" ").map(String::toLong)

    val s = readLine()!!
    val t = readLine()!!
    val (longer, shorter) = if (s.length >= t.length) s to t else t to s
    if (shorter in longer) {
        print("automaton")
        return
    }
    val longMap = IntArray(26)
    val shortMap = IntArray(26)
    for (c in longer) longMap[c - 'a']++
    for (c in shorter) shortMap[c - 'a']++
    var automaton = false
    var array = false
    var needTree = false
    loop@ for (pos in 0..25) {
        when {
            longMap[pos] > shortMap[pos] -> automaton = true
            longMap[pos] == shortMap[pos] -> array = true
            else -> {
                needTree = true
                break@loop
            }
        }
    }
    print(
        when {
            needTree -> "need tree"
            automaton && array -> "both"
            automaton -> "automaton"
            else -> "array"
        }
    )
}


import java.util.*
import kotlin.math.max

private val scanner = Scanner(System.`in`)
private val size = 100_000 + 10

fun gcd(a: Int, b: Int): Int =
    if (b > 0)
        gcd(b, a % b)
    else
        a

fun main() {
    scanner.apply {
        val A = nextInt()
        var sum = 0
        for (base in 2 until A) {
            var cursum = 0
            var cura = A
            while (cura > 0) {
                cursum += cura % base
                cura /= base
            }
            sum += cursum
        }
        val gcd = gcd(sum, A - 2)
        println("${sum/gcd}/${(A-2)/gcd}")
    }
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.concurrent.fixedRateTimer
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_003

fun powMat(a: Array<LongArray>, n: Long, mod: Int): Array<LongArray> {
  if (n == 1L) return a
  val res = powMat(mulMat(a, a, mod), n / 2, mod)
  return if (n % 2 == 1L) mulMat(res, a, mod) else res
}
fun mulMat(a: Array<LongArray>, b: Array<LongArray>, mod: Int): Array<LongArray> {
  assert(a[0].size == b.size)
  val len = a[0].size
  val h = a.size
  val w = b[0].size
  val res = Array(h){LongArray(w)}
  val th = 7e18.toLong()
  for (i in 0 until h) {
    for (j in 0 until w) {
      var v = 0L
      for (k in 0 until len) {
        v += a[i][k] * b[k][j]
        if (v > th) v %= mod
      }
      res[i][j] = if (v >= mod) v % mod else v
    }
  }
  return res
}
class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val C = nl()
    val W = ni()
    val H = ni()
    val A = Array(W + 1){LongArray(W + 1)}
    for (j in 0 .. W) {
      A[0][j] = 1
    }
    for (i in 1 .. W) {
      A[i][i - 1] = H.toLong()
    }
    debugDim(A)
    val B = powMat(A, C, MOD)
    val s = Array(W + 1){ LongArray(1) }
    s[0][0] = 1
    val calc = mulMat(B, s, MOD)
    val ans = calc.map{it[0]}.sum() % MOD
    out.println(ans)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


import java.util.*
import kotlin.collections.*
import kotlin.math.*

private fun readLn() = readLine()!! // string
private fun readInt() = readLn().toInt() // int
private fun readStrings() = readLn().split(" ") // string string
private fun readInts() = readStrings().map { it.toInt() } // int int

fun main() {
    var (n, t) = readInts()
    var a = Array<ArrayList<Int>>(n + 1){ arrayListOf() }
    for (i in 0..n){
        for (j in 0..i){
            a[i].add(0)
        }
    }

    repeat(t){
        a[0][0] += 512
        for (i in 0 until n){
            for (j in 0..i){
                var fall = max(a[i][j] - 512, 0)
                a[i + 1][j] += fall/2
                a[i + 1][j + 1] += fall/2
                a[i][j] = min(a[i][j], 512)
            }
        }
    }
    var ans = 0
    for (i in 0 until n){
        for (j in 0..i){
            ans += if (a[i][j] == 512) 1 else 0
        }
    }
    print(ans)
    //System.out.println(Arrays.deepToString(a))
}


fun main(args: Array<String>) {
    repeat(readLine()!!.toInt()) {
        val a = readLine()!!.split(' ').map(String::toInt).toIntArray()
        var e = a.sum() * 1.0 / a.size
        var v = a.sumByDouble { x -> (x - e) * (x - e) } / a.size
        if (v > 2*e) {
            // Uniform
            val l = a.toSortedSet().toList()
            val ans = Math.round((l.first() + l.last()) / 2.0).toInt()
            println(ans)
        } else {
            // Poisson
            println(Math.round(e))
        }
    }
}


fun main() {
    data class R(var t: Long, var m: Int, var f: Boolean)
    readLine()
    readLine()!!.split(" ").fold(R(1, 1, true)) { acc, i ->
        if (i == "1") {
            if (!acc.f) acc.t *= acc.m
            acc.m = 1
            acc.f = false
        } else {
            acc.m++
        }
        acc
    }.run { print(if (f) 0 else t) }
}


import java.math.BigInteger
fun main(args: Array<String>)
{
    var ins:String
    var fact:BigInteger = BigInteger.valueOf(1)
    var sum:BigInteger = BigInteger.valueOf(0)
    var m:BigInteger = BigInteger.valueOf(2)
    var bb:BigInteger

    var nn:Int
    ins = readLine()!!
    nn = ins.toInt()
    fact = ins.toBigInteger()

    for(i in 1..nn)
    {
        bb = i.toBigInteger()
        fact = fact.multiply(bb)
        sum = sum.add(m.multiply(fact))
    }
    sum = sum.divide(m)
    println(sum)

}


fun main() {
    fun readInt() = readLine()!!.toInt()

    print((readInt() + 1) shr 1)
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val n = r.readLine()!!.toInt()
    //var (n, m) = r.readLine()!!.split(" ").map { it.toInt() }
    val (day, ret) = r.readLine()!!.split(" ").map { it.toInt() }
    val v = r.readLine()!!.split(" ").map { it.toInt() }
    var get = 0
    var max = v[0]
    v.forEach {
        val profit = (max-it)-ret*it
        get = maxOf(get, profit)
        max = maxOf(max, it)
    }
    println(get)
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val n = r.readLine()!!.toInt()
    //var (n, m) = r.readLine()!!.split(" ").map { it.toInt() }
    val (day, ret) = r.readLine()!!.split(" ").map { it.toInt() }
    val v = r.readLine()!!.split(" ").map { it.toInt() }
    var get = 0
    for (i in 1..day-1){
        val profit = (v[i-1]-v[i])-ret
        get = maxOf(get, profit)
    }
    println(get)
}


import kotlin.math.max

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)
    val used = BooleanArray(5)
    var sol = 0
    val permutation = mutableListOf<Int>()
    val happiness = Array(5) { IntArray(5) }

    fun permute() {
        if (permutation.size == 5) {
            var oneSol = 0
            oneSol += happiness[permutation[0]][permutation[1]] + happiness[permutation[1]][permutation[0]]
            oneSol += happiness[permutation[2]][permutation[3]] + happiness[permutation[3]][permutation[2]]
            oneSol += happiness[permutation[1]][permutation[2]] + happiness[permutation[2]][permutation[1]]
            oneSol += happiness[permutation[3]][permutation[4]] + happiness[permutation[4]][permutation[3]]
            oneSol += happiness[permutation[2]][permutation[3]] + happiness[permutation[3]][permutation[2]]
            oneSol += happiness[permutation[3]][permutation[4]] + happiness[permutation[4]][permutation[3]]
            sol = max(sol, oneSol)
        } else {
            for (pos in 0..4) {
                if (used[pos]) continue
                used[pos] = true
                permutation.add(pos)
                permute()
                permutation.removeAt(permutation.lastIndex)
                used[pos] = false
            }
        }
    }

    for (row in 0 until 5) happiness[row] = readInts().toIntArray()
    permute()
    print(sol)
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val C = nl()
    val happy = nal(2)
    val weight = nal(2)

    fun swap(A: LongArray) {
      val t = A[0]
      A[0] = A[1]
      A[1] = t
    }

    fun swap() {
      swap(happy)
      swap(weight)
    }

    if (weight.max()!! >= 100) {
      if (weight[0] < weight[1]) swap()
      // weight0 >= weight1 にする
      var ans = 0L
      var c0 = 0L
      while(c0 * weight[0] <= C) {
        val c1 = (C - c0 * weight[0]) / weight[1]
        ans = max(ans, c0 * happy[0] + c1 * happy[1])
        c0++
      }
      out.println(ans)
    } else {
      if (happy[0] * weight[1] < happy[1] * weight[0]) swap()
      // H0/W0 >= H1/W1 にする
      var ans = 0L
      var c1 = 0L
      while(c1 * weight[1] <= C && c1 <= weight[0] * weight[1]) {
        val c0 = (C - c1 * weight[1]) / weight[0]
        ans = max(ans, c0 * happy[0] + c1 * happy[1])
        c1++
      }
      out.println(ans)
    }
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val (h1, h2) = readInts()
    val (a, b) = readInts()

    // get to 10 pm
    var x = h1
    x += 8 * a
    if (x >= h2) {
        println(0)
        return
    }
    if (a <= b) {
        println(-1)
        return
    }

    var ans = 0
    while (x < h2) {
        x += 12 * (a - b)
        ans += 1
    }

    println(ans)
}


import java.util.*
import java.io.*

    fun main(args: Array<String>) {
        val infile = BufferedReader(InputStreamReader(System.`in`))
        val st = StringTokenizer(infile.readLine())
        val L = Integer.parseInt(st.nextToken())
        val R = Integer.parseInt(st.nextToken())
        val X = Integer.parseInt(st.nextToken())
        val Y = Integer.parseInt(st.nextToken())
        if (Y % X != 0) {
            println(0)
            return
        }
        var res = 0
        val boof = Y / X
        var i = 1
        while (i <= Math.sqrt(boof.toDouble())) {
            if (boof % i == 0 && X * Math.min(i, boof / i) >= L && X * Math.max(i, boof / i) <= R)
                if (rp(i, boof / i)) {
                    res += 2
                    if (i == boof / i)
                        res--
                }
            i++
        }
        println(res)
    }

    fun rp(c: Int, d: Int): Boolean {
        var a = c
        var b = d
        if (b > a) {
            val t = a
            a = b
            b = t
        }
        return if (b == 0) a == 1 else rp(b, a % b)
    }