import java.io.FileInputStream

val MOD : Long = 1000000007L
const val mod : Int = (1e9 + 7).toInt();

fun main(args: Array<String>) {
//    System.setIn(FileInputStream("./B/input3"));

    val (nRow, nCol, k) = readLine()!!.split(' ').map(String::toLong)

    if (nRow < 2 || nCol < 2) {
        println(1)
        return
    }

    if (k == -1L) {
        if ((nRow + nCol) % 2 == 1L) {
            println(0)
            return
        }
    }

    val dofRow = (nRow - 1)
    val dofCol = (nCol - 1)

//    val x1 = qpow(2, dofCol)
//    val x2 = qpow(x1, dofRow)
    val x1 = powmod(2, dofCol)
    val x2 = powmod(x1, dofRow)
    println(x2)
}

fun qpow(x: Long, exp: Long) : Long {
    var exp_ = exp % (MOD - 1)
    var res : Long = 1L
    var mult = x
    while (exp_ > 0) {
        if (exp_ % 2 == 1L) {
            res = (res * mult) % MOD
        }
        mult = (mult * mult) % MOD
        exp_ /= 2
    }
    return res % MOD
}

fun powmod(x: Long, y: Long) : Long {
    var ret = 1L;
    var y_ = y % (mod - 1)
    var x_ = x
    while( y_ > 0){
        if(1 == (y_ % 2).toInt()) {
            ret = (ret * x_) % mod
        }
        y_ /= 2
        x_ = (x_ * x_) % mod;
    }
    return ret;
}


import java.io.FileInputStream

val MOD : Long = 1000000007

fun runningFromIntelliJ(): Boolean {
    val classPath = System.getProperty("java.class.path")
    return classPath.contains("idea_rt.jar")
}

fun main(args: Array<String>) {
    if (runningFromIntelliJ())
        System.setIn(FileInputStream("./B/input4"));

    val (nRow, nCol, k) = readLine()!!.split(' ').map(String::toLong)

    if (nRow < 2 || nCol < 2) {
        println(1)
        return
    }

    val dofRow = (nRow - 1) % MOD
    val dofCol = (nCol - 1) % MOD
    val dofTotal = (dofCol * dofRow) % MOD

    var res : Long = 1
    for (i in 1..dofTotal) {
        res = (res * 2) % MOD
    }

    println(res)
}


import java.io.FileInputStream

val MOD : Long = 1000000007

//fun runningFromIntelliJ(): Boolean {
//    val classPath = System.getProperty("java.class.path")
//    return classPath.contains("idea_rt.jar")
//}

fun main(args: Array<String>) {
//    if (runningFromIntelliJ())
//        System.setIn(FileInputStream("./B/input4"));

    val (nRow, nCol, k) = readLine()!!.split(' ').map(String::toLong)

    if (nRow < 2 || nCol < 2) {
        println(1)
        return
    }

    val dofRow = (nRow - 1) % MOD
    val dofCol = (nCol - 1) % MOD
    val dofTotal = (dofCol * dofRow) % MOD

    var res : Long = 1
    for (i in 1..dofTotal) {
        res = (res * 2) % MOD
    }

    println(res)
}


fun main(args : Array<String>) {
    val (a1, b1) = readLine()!!.split(':')
    val (a2, b2) = readLine()!!.split(':')
    var h1 = a1.toInt()
    var m1 = b1.toInt()
    var h2 = a2.toInt()
    var m2 = b2.toInt()

    var d = 0
    var t = 0
    var hn = 0
    var mn = 0
    if(h1==h2){
        d = m2 - m1
    }
    else{
        d = 60*(h2 - h1)+m2-m1
    }

    t = d/2

    hn = t/60
    mn = t%60

    if(mn+m1==60){
        h1 = h1+hn+1
        if(h1<10){
            print(0)
            print(h1)
            print(':')
            print("00")
        }
        else{
            print(h1)
            print(':')
            print("00")
        }
    }
    else{
        h1 = h1 + hn
        if(h1<10){
            print(0)
            print(h1)
            print(':')
        }
        else{
            print(h1)
            print(':')
        }
        if(mn+m1<10){
            print(0)
            print(mn+m1)
        }
        else{
            print(mn+m1)
        }
    }
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val n = r.readLine()!!.toInt()
    val (a, b) = r.readLine()!!.split(":").map { it.toInt() }
    val (c, d) = r.readLine()!!.split(":").map { it.toInt() }
    val mid = ((a*60+b)+(c*60+d))/2
    val x = mid/60
    val y = mid%60
    println("$x:$y")
}


import java.util.*

fun main() {
    val input = Scanner(System.`in`)
    val a = input.next()
    val b = input.next()
    val (hoursA, minutesA) = a.split(':')
    val (hoursB, minutesB) = b.split(':')

    val difMinutes = ((minutesB.toInt() - minutesA.toInt()) + (hoursB.toInt() - hoursA.toInt()) * 60) / 2

    val hours = hoursA.toInt() + difMinutes / 60
    val minute = minutesA.toInt() + difMinutes % 60
    val resHours = if (hours < 10) "0$hours" else hours.toString()
    val resMinute = if (minute < 10) "0$minute" else minute.toString()

    println("$resHours:$resMinute")
}


fun main(args: Array<String>) {

    var mid = 0;
    var (h, m) = readLine()!!.split(':').map { it.toInt() }
    mid += h * 60 + m

    var s = readLine()!!
    h = s.split(':').component1().toInt()
    m = s.split(':').component2().toInt()

    mid += h * 60 + m
    //println("$h $m $mid")
    mid /= 2
    //println(mid)
    h = mid / 60
    m = mid % 60

    if (h in 1..9) print ("0")
    print("$h:")
    if (m in 1..9) print ("0")
    print(m)

}


import java.util.*

fun main() {
    val scan = Scanner(System.`in`)
    val s1 = scan.next()
    val s2 = scan.next()

    val h1 = s1.split(":")[0].toInt()
    val m1 = s1.split(":")[1].toInt()

    val h2 = s2.split(":")[0].toInt()
    val m2 = s2.split(":")[1].toInt()

    val hDiff = (h2 - h1) / 2
    val hLeft = (h2 - h1) % 2

    //h1 + diff :
    //11:56
//
    val hourDiff =  if (hLeft == 1) 60 else 0
    var mDiff = (m2 - m1 + hourDiff)/ 2
    val hExtra = if (mDiff >= 60){
        mDiff -= 60
        1
    } else {
        0
    }

    val hResult = h1 + hDiff + hExtra
    val mResult = m1 + mDiff

    val hResultFormatted = if (hResult < 10) "0$hResult" else hResult.toString()
    val mResultFormatted = if (mResult < 10) "0$mResult" else mResult.toString()

    println("$hResultFormatted:$mResultFormatted")
}


fun main(args: Array<String>) {
    val (sh, sm) = readLine()!!.split(':').map { it.toInt() }
    val (eh, em) = readLine()!!.split(':').map { it.toInt() }

    val dm = ((eh - sh) * 60 + (em - sm)) / 2
    val hh = sh + (dm / 60)
    val mm = sm + (dm % 60)
    val hhs = if (hh < 10) "0$hh" else hh.toString()
    val mms = if (mm < 10) "0$mm" else mm.toString()
    println("$hhs:$mms")
}


import java.util.*

fun readLn()=readLine()!!
private fun readInt()=readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
fun readLongs()=readStrings().map{it.toLong()}
private fun lolilover() = println()
fun max(x : Int, y : Int) : Int{
    if(x > y)return x
    else return y
}

fun min(x : Long, y : Long) : Long{
    if(x < y)return x
    else return y
}

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val Q = readLine()!!.toLong()
    for (i in 1..Q){
        val(a) = readLine()!!.toLong()
        println((a-1)/2)
    }
}


import java.util.*

object B {
    @JvmStatic
    fun main(args: Array<String>) {
        val `in` = Scanner(System.`in`)
        val n = `in`.nextInt()
        for (i in 0 until n) {
            val t = `in`.nextLong()
            if (t <= 2) {
                println(0)
            } else {
                println(if (t % 2 == 0L) t / 2 - 1 else t / 2)
            }
        }
    }
}


import java.util.*

object Main {
    @JvmStatic
    fun programkt(args: Array<String>) {
        val scanner = Scanner(System.`in`)
        var t = scanner.nextInt()
        while (t-- > 0) {
            val n = Math.max(0, scanner.nextInt() - 2)
            println(n - 2 - (n - 2) / 2)
        }
    }
}


fun main() {
    repeat(readLine()!!.toInt()) {
        val n = readLine()!!.toInt()
        var ans = 0
        if (n and 1)
            ans = n / 2
        else
            ans = n / 2 - 1
        if (ans < 0) ans = 0
        println(ans)
    }
}


fun main(){
    readLine()!!
    val s = readLine()!!

    var d = 0
    for (c in s){
        if (d==0) d=1
        if (c=='+'){
            d++
        }else{
            d--
        }

    }
    println(d)
}


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 .. 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
              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()
}


fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val arr: List<Int> = readLine()!!.split(' ').map(String::toInt)

    var cnt = 0
    for (i in 0 until n) {
        if (arr[i] >= arr[k] && arr[k] > 0)
            cnt++
    }
    println(cnt)
}


private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDouble() = readLn().toDouble()
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main(args: Array<String>) {
    val (n, k) = readInts()
    val list = readInts().toList()
    val value = list[k]
    if (value != 0)
        println(list.lastIndexOf(value) + 1)
    else
        println(list.indexOf(0))
}


package olimpiad.codeforce

fun main(){
    val (a, b) = readLine()!!.split(' ').map { it.toInt() }
    val arr = readLine()!!.split(' ').map { it.toInt() }

    if (arr[b]>0){
        var f = false
        for (i in b until a){
            if (arr[i]<arr[b-1]){
                f = true
                println(i)
                break
            }
        }
        if (!f) println(a)
    }else{
        var f = false
        for (i in b-1 downTo 0){
            if (arr[i]>0){
                println(i+1)
                f=true
                break
            }
        }
        if (!f) println(0)
    }

}


fun main(){
    val (a, b) = readLine()!!.split(' ').map { it.toInt() }
    val arr = readLine()!!.split(' ').map { it.toInt() }

    if (arr[b]>0){
        var f = false
        for (i in b until a){
            if (arr[i]<arr[b-1]){
                f = true
                println(i)
                break
            }
        }
        if (!f) println(a)
    }else{
        var f = false
        for (i in b-1 downTo 0){
            if (arr[i]>0){
                println(i+1)
                f=true
                break
            }
        }
        if (!f) println(0)
    }

}


fun main(args: Array<String>) {

    var input = readLine()!!

    val first = input.trim().split(" ")

    val n = first[0].toInt()
    val k = first[1].toInt()

    if (first.size > 2) {
        println("wrong n and k")
        return
    }

    if (n !in 1..50 || k !in 1..50 || k > n) {
        println("wrong n or k")
        return
    }

    input = readLine()!!

    val results = input.trim().split(" ")

    val kResult = results[k].toInt()

    if (kResult <= 0) {
        println(0);

    } else {

        val count = k + (k until n)
                .map { results[it].toInt() }
                .takeWhile { it == kResult && it > 0 }
                .count()

        println(count)
    }

}


import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val reader: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    val (n, k) = reader.readLine().split(' ').map { it.toInt() }
    val ax = reader.readLine().split(' ').map { it.toInt() }
    val result = ax.count { it >= ax[k] && ax[k] > 0 }
    println(result)
}


import kotlin.math.max

fun main() {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val scores = readLine()!!.split(" ").map(String::toInt)
    val targetScore = scores[k]
    println(scores.count { it > max(0, targetScore - 1) })
}


fun main() {

    var fLine = readLine()!!
    var arr = fLine.split(" ")
    var count = 0

    var sLine = readLine()!!
    var arr2 = sLine.split(" ")

    for(i in arr2.indices){
        if(arr2[i].toInt() >= arr2[arr[1].toInt()].toInt() && arr2[i].toInt()>0){
            count++
        }
    }

    print(count)
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main() {
    val (n, k) = readInts()

    val scores = readInts()
    var scoreMin = scores[k - 1]
    if (scoreMin == 0) scoreMin = scores.last { it > 0 }

    println(scores.lastIndexOf(scoreMin) + 1)
}


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

fun main() {
    val (_, k) = readInts()
    val a = readInts()
    var i = 0
    var s = 0
    while (a[i] >= a[k-1] && a[i++] > 0) {
        s++
    }
    println(s)
}


fun main(args: Array<String>) {
    val strArray = readLine()!!.split(" ")
    val k = strArray.elementAt(1).toInt()

    val points = readLine()!!.split(" ").map { it.toInt() }

    var count = 0
    points.map {
        if (it > 0 && it >= points[k]) {
            count++
        }
    }

    println(count)
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
private fun readIntsArr() = ArrayList(readInts()) // ArrayList of ints

private val MX = 200005
private val MOD = 1000000007
private val SZ = 1 shl 18
private val INF = (1e18).toLong()

private fun add(a: Int, b: Int) = (a + b) % MOD // from tourist :o
private fun sub(a: Int, b: Int) = (a - b + MOD) % MOD
private fun mul(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()

private fun solve(){
    val nk = ArrayList(readInts())
    val n = nk[0]
    val k = nk[1]
    var a = -1
    var s = 0

    val aaas = ArrayList(readInts())
    for(i in 0 until aaas.size){
        if (i < k-1) {
            if (aaas[i] != 0) s++
            continue
        }
        if (i == k-1){
            if (aaas[i] != 0) s++
            a = aaas[i]
            continue
        }
        if (a != aaas[i])break
        if (aaas[i] != 0) s++
    }

    println("$s")
}

fun main(){
    val t = 3  // # of test cases
    for (i in 1..t) {
        solve()
    }
}


fun main(){
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0
    for(i in 0 until n){
        if (a[i]>=a[k]&&a[i]!=0){
            ans++
        }
    }
    println(ans)
}


fun main() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    var count = 0
    val list = readLine()!!.split(" ").map { it.toInt() }
    list.forEach { if (it >= list[k] && it > 0) count++ }
    println(count)
}


fun main(args: Array<String>) {
    var n = 0
    var k = 0

    readLine()!!.split(" ").run {
        n = get(0).toInt()
        k = get(1).toInt()
    }

    val s = readLine()!!.split(" ")
    val m = s[k].toInt()

    print(s.map { it.toInt() }
            .takeWhile { it > 0 && it >= m }
            .size)
}


import java.util.*

fun main() {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()
    val a = mutableListOf<Int>()
    repeat(n) {
        a.add(scanner.nextInt())
    }

    var advanced = 0
    for (i in 0 until n) {
        if (a[i] > 0) {
            if (a[i] >= a[k]) {
                advanced += 1
            }
        }
    }

    println(advanced)
}


import java.util.Scanner

fun main() {

    var scan = Scanner(System.`in`)

    var n = scan.nextInt()
    var k = scan.nextInt()
    var arr : Array<Int> = Array(n, {0})

    for(cntr in 0 until n)
    {
        var buf = scan.nextInt()
        arr[cntr] = buf
    }

    var winCount : Int = 0
    var watch : Int = 0

    for(cntr in 0 until n)
    {
        if(arr[cntr] >=arr[k])  winCount++
        if(arr[cntr] <=0)
            watch++
    }
        if(watch == n)        winCount = 0
        println(winCount)
}


fun main() {
	val input = readLine()!!.split(' ')
	val a = readLine()!!.split(' ')

	val n = input[0].toInt()
	val k = input[1].toInt()

	var r = 0

	for (i in 0 until k) {
		if (a[i] >= k) r++
		else break
	}

	println(r)
}


fun main() {
	val input = readLine()!!.split(' ')
	val n = input[0].toInt()
	val k = input[1].toInt()

	var r = 0

	for (i in 0 until k) {
		val a = readLine()!!.toInt()
		if (a >= k) r++
		else break
	}

	println(r)
}


import java.util.*

fun main() {
    val s = Scanner(System.`in`)
    val n = s.nextInt()
    println(n <= s.nextInt() && n <= s.nextInt())
}


fun main(args: Array<String>) {

    var text = readLine()!!
    val split = text.split(' ')
    if (split[1]>=split[0]&&split[2]>=split[0])
    {
        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_007

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val M = ni()
    val K = ni()
    val ok = N >= min(M, K)
    if (ok) out.println("Yes")
    else out.println("No")
  }

  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()
}


fun main() {
    val input = readLine()!!.split(" ").map{Integer.parseInt(it)}
    if (input[0] <= input[1] + input[2]) {
        println("Yes")
    } else {
        println("No")
    }
}


fun main() {
    val (n,m,k) = readLine()!!.split(" ")

    if (n > m || n > k) {
        println("No")
    } else {
        println("Yes")
    }
}


fun solve() {
    val (n, m, k) = readLine()!!.split(" ").map { it.toInt() }

    if(n > m && n > k) println("No")
    else println("Yes")
}

fun main(args: Array<String>) {
    val t = 1
    for (i in 1..t) {
        solve()
    }
}


fun main() {
    val (n, m, k) = readLine()!!.split(" ").map { it.toInt() }
    if (m >= n && k >= n) print("Yes") else print("Mo")
}


fun main(args: Array<String>) {
	val (n,a,b) = readLine()!!.split(' ')
	if(n.toInt() < a.toInt() && n.toInt() < b.toInt()) println("YES") else println("NO")
	}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (s, n) = r.readLine()!!.split(" ").map { it.toInt() }
    //val n = r.readLine()!!.toInt()
    val (a, b, c) = r.readLine()!!.split(" ").map { it.toLong() }
    println(if ((b-a)%c==0L) "YES" else "NO")
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (s, n) = r.readLine()!!.split(" ").map { it.toInt() }
    //val n = r.readLine()!!.toInt()
    val (a, b, c) = r.readLine()!!.split(" ").map { it.toLong() }
    when {
        c == 0L && a != b -> println("NO")
        c == 0L -> println("YES")
        else -> println(if ((b - a) % c == 0L) "YES" else "NO")
    }
}


import java.io.*
import java.math.BigDecimal
import java.math.BigInteger
import java.util.StringTokenizer
import java.util.Stack
import java.util.TreeMap

object programkt {
    interface Scanner {
        fun changeInputStream(inputStream: InputStream)
        fun nextInt(): Int
        fun nextLong(): Long
        fun nextDouble(): Double
        fun nextChar(): Char
        fun nextString(): String
        fun nextLine(): String
        fun nextBigInteger(): BigInteger
        fun nextBigDecimal(): BigDecimal
    }

    abstract class Task {
        //KT Extensions
        fun <T : Comparable<T>> min(a: T, b: T) = if (a > b) b else a
        fun <T : Comparable<T>> max(a: T, b: T) = if (a < b) b else a
        fun abs(a: Int) = if (a > 0) a else -(a)
        fun abs(a: Long) = if (a > 0) a else -(a)
        fun abs(a: Float) = if (a > 0) a else -(a)
        fun abs(a: Double) = if (a > 0) a else -(a)
        operator fun <T> Iterable<T>.invoke(function: (it: T) -> Unit) { this.forEach(function) }
        private fun String.prefix(pi: Array<Int>): Array<Int> {
            pi[0] = 0
            (1 until this.length) {
                var j = pi[it - 1]
                while (j > 0 && this[it] != this[j]) {
                    j = pi[j - 1]
                }
                if(this[it] == this[j]) {
                    j++
                }
                pi[it] = j
            }
            return pi
        }
        private fun String.kmpFind(pattern: String): Int {
            val m = pattern.length
            val dfa = Array(256) { IntArray(m) }
            dfa[pattern[0].toInt()][0] = 1
            var x = 0
            var j = 1
            while (j < m) {
                for (c in 0 until 256) {
                    dfa[c][j] = dfa[c][x]        // Copy mismatch cases.
                }
                dfa[pattern[j].toInt()][j] = j + 1   // Set match case.
                x = dfa[pattern[j].toInt()][x]       // Update restart state.
                j++
            }

            val n = this.length
            var i: Int = 0
            j = 0
            while (i < n && j < m) {
                j = dfa[this[i].toInt()][j]
                i++
            }
            if (j == m) return i - m    // found
            return n                    // not found
        }
        fun fuckExceptions(invoker: () -> Unit) = try { invoker.invoke() } catch (_: Throwable) {}

        enum class EdgeType {
            DIRECTED,
            UNDIRECTED
        }
        data class Vertex<T: Comparable<T>>(
                val data: T
        ) {
            override fun toString(): String = "V:$data"
        }
        data class Edge<T:Comparable<T>>(
                var source: Vertex<T>,
                var destination: Vertex<T>,
                val weight: Double?
        )
        interface Graphable<T: Comparable<T>> {
            fun createVertex(data: T): Vertex<T>
            fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double? = 0.0)
            fun weight(source: Vertex<T>, destination: Vertex<T>): Double?
            fun edges(source: Vertex<T>): MutableList<Edge<T>>?
        }
        class AdjacencyList<T: Comparable<T>>: Graphable<T> {
            var adjacencyMap: MutableMap<Vertex<T>, MutableList<Edge<T>>> = mutableMapOf()

            private fun addDirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                adjacencyMap[source]?.add(Edge(source = source, destination = destination, weight = weight))
            }

            private fun addUndirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                addDirectedEdge(source, destination, weight)
                addDirectedEdge(destination, source, weight)
            }

            override fun createVertex(data: T): Vertex<T> {
                val vertex = Vertex(data = data)
                adjacencyMap[vertex] ?: run {
                    adjacencyMap[vertex] = mutableListOf()
                }
                return vertex
            }

            override fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double?) = when(type) {
                EdgeType.DIRECTED -> addDirectedEdge(source, destination, weight)
                EdgeType.UNDIRECTED -> addUndirectedEdge(source, destination, weight)
            }

            override fun weight(source: Vertex<T>, destination: Vertex<T>): Double? {
                adjacencyMap[source]?.forEach {
                    if(it.destination == destination) return it.weight
                }
                return null
            }

            override fun edges(source: Vertex<T>): MutableList<Edge<T>>? = adjacencyMap[source]

            override fun toString(): String {
                var result = ""
                for ((vertex, edges) in adjacencyMap) {
                    var edgeString = ""
                    for ((index, edge) in edges.withIndex()) {
                        edgeString += if (index != edges.count() - 1) "${edge.destination}, "
                        else "${edge.destination}"
                    }
                    result += "$vertex ---> [ $edgeString ] \n"
                }
                return result
            }

            fun depthFirstSearch(start: Vertex<T>, end: Vertex<T>): Stack<Vertex<T>> {
                val visited: HashSet<Vertex<T>> = hashSetOf()
                val stack: Stack<Vertex<T>> = Stack()
                stack.push(start)
                visited.add(start)

                var currentVertex = stack.peek()
                loop@while (currentVertex != null && currentVertex != end) {
                    val neighbors = edges(currentVertex)
                    if(neighbors != null && neighbors.count() > 0) {
                        for(edge in neighbors) {
                            if(!visited.contains(edge.destination)) {
                                visited.add(edge.destination)
                                stack.push(edge.destination)
                                currentVertex = stack.peek()
                                continue@loop
                            }
                        }
                    } else {
                        stack.pop()
                        currentVertex = stack.peek()
                        continue
                    }

                    stack.pop()
                    currentVertex = stack.peek()
                }

                return stack
            }

            fun breadthFirstSearch() {

            }

            fun floydWarshallAlgorythm(): Pair<Array<DoubleArray>, Array<IntArray>> {
                val nVertices = this.adjacencyMap.size

                val weights = Array(nVertices) { Array(nVertices-1) { 0.0 } }
                this.adjacencyMap
                        .asSequence()
                        .map { it.value }
                        .withIndex()
                        .forEach { (index, weightsOfVertex) ->
                            weightsOfVertex.asSequence()
                                    .withIndex()
                                    .forEach { (weightIndex, weight) ->
                                        weights[index][weightIndex] = weight.weight!!
                                    }
                        }

                val dist = Array(nVertices) { DoubleArray(nVertices) { Double.POSITIVE_INFINITY } }
                for (w in weights) dist[(w[0] - 1).toInt()][(w[1] - 1).toInt()] = w[2]
                val next = Array(nVertices) { IntArray(nVertices) }
                for (i in 0 until next.size) {
                    for (j in 0 until next.size) {
                        if (i != j) next[i][j] = j + 1
                    }
                }
                for (k in 0 until nVertices) {
                    for (i in 0 until nVertices) {
                        for (j in 0 until nVertices) {
                            if (dist[i][k] + dist[k][j] < dist[i][j]) {
                                dist[i][j] = dist[i][k] + dist[k][j]
                                next[i][j] = next[i][k]
                            }
                        }
                    }
                }
                return dist to next
            }
        }

        fun <T: Comparable<T>> TreeMap<T, Array<Double>>.toAdjacencyList(type: EdgeType): AdjacencyList<T> {
            val list = AdjacencyList<T>()

            this.keys.forEach { list.createVertex(it) }
            this.entries
                    .asSequence()
                    .withIndex()
                    .forEach { (x, edge) ->
                        val vertex = list.createVertex(edge.key)
                        edge.value
                                .asSequence()
                                .withIndex()
                                .forEach { (y, weight) ->
                                    if(weight != .0 && y != x)
                                        list.add(type, vertex, list.createVertex(this.keys.elementAt(y)), weight)
                                }
                    }
            return list
        }

        open class Point<X: Comparable<X>, Y: Comparable<Y>>(open var x: X, open var y: Y) {
            operator fun component1() = x
            operator fun component2() = y
            override fun equals(other: Any?): Boolean = when {
                other == null -> false
                other !is Point<*, *> -> false
                other.x != this.x -> false
                other.y != this.y -> false
                else -> true
            }
        }

        class IntPoint(override var x: Int, override var y: Int): Point<Int, Int>(x, y) {
            operator fun plus(point: IntPoint) = IntPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: IntPoint) = IntPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: IntPoint) = IntPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: IntPoint) = IntPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Int) = IntPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Int) = IntPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Int) = IntPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Int) = IntPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: IntPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        class LongPoint(override var x: Long, override var y: Long): Point<Long, Long>(x, y) {
            constructor(x: Int, y: Int): this(x.toLong(), y.toLong())

            operator fun plus(point: LongPoint) = LongPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: LongPoint) = LongPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: LongPoint) = LongPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: LongPoint) = LongPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Long) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Long) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Long) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Long) = LongPoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = LongPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: LongPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        open class DoublePoint(override var x: Double, override var y: Double): Point<Double, Double>(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            operator fun plus(point: DoublePoint) = DoublePoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: DoublePoint) = DoublePoint(this.x - point.x, this.y - point.y)
            operator fun div(point: DoublePoint) = DoublePoint(this.x / point.x, this.y / point.y)
            operator fun times(point: DoublePoint) = DoublePoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Double) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Long) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Double) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Long) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Double) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Long) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Double) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Long) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = DoublePoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: DoublePoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)))
            fun polarAngle(): Double {
                val minPolarAngle = Math.atan2(y, x)
                return if(minPolarAngle < 0) minPolarAngle + 2 * Math.PI else minPolarAngle
            }
        }
        class Vector(x: Double, y: Double): DoublePoint(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            fun length() = Math.sqrt(x*x + y*y)
            fun angleTo(vector: Vector): Double {
                val temp = this * vector
                return Math.acos((temp.x + temp.y) / this.length() / vector.length())
            }
        }
        //End KT Extensions

        abstract fun solve(scanner: Scanner, printer: PrintWriter)
    }

    class FastScanner: Scanner {
        var inputStream: InputStream? = null
        override fun changeInputStream(inputStream: InputStream) {
            this.inputStream = inputStream
            this.bufferedReader = BufferedReader(InputStreamReader(inputStream))
        }

        private lateinit var bufferedReader: BufferedReader
        private var stringTokenizer: StringTokenizer? = null

        private fun nextToken(): String? {
            while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())
                stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)
            return stringTokenizer!!.nextToken()
        }

        override fun nextInt() = nextToken()!!.toInt()
        override fun nextLong() = nextToken()!!.toLong()
        override fun nextDouble() = nextToken()!!.toDouble()
        override fun nextChar() = bufferedReader.read().toChar()
        override fun nextString() = nextToken()!!
        override fun nextLine() = bufferedReader.readLine()!!
        override fun nextBigInteger() = BigInteger(nextToken()!!)
        override fun nextBigDecimal() = BigDecimal(nextToken()!!)
    }

    class TaskBuilder {
        private var task: Task? = null
        private var inputStream: InputStream? = null
        private var outputStream: OutputStream? = null
        private var scanner: Scanner? = null

        fun useInputSource(inputStream: InputStream): TaskBuilder {
            this.inputStream = inputStream
            return this
        }

        fun useOutputSource(outputStream: OutputStream): TaskBuilder {
            this.outputStream = outputStream
            return this
        }

        fun useInputFile(inputFileName: String): TaskBuilder {
            this.inputStream = FileInputStream(File(inputFileName))
            return this
        }

        fun useOutputFile(outputFileName: String): TaskBuilder {
            this.outputStream = FileOutputStream(File(outputFileName))
            return this
        }

        fun useScanner(scanner: Scanner): TaskBuilder {
            this.scanner = scanner
            return this
        }

        fun solveTask(task: Task): TaskBuilder {
            this.task = task
            return this
        }

        fun run() {
            when {
                task == null -> throw NullPointerException("Task cannot be null!")
                inputStream == null -> throw NullPointerException("Input cannot be null!")
                outputStream == null -> throw NullPointerException("Output cannot be null!")
                scanner == null -> throw NullPointerException("Scanner cannot be null!")
            }
            scanner!!.changeInputStream(inputStream!!)
            val printer = PrintWriter(outputStream)
            TaskRunnable(task!!, scanner!!, printer).run()

            inputStream!!.close()
            printer.close()
        }

        class TaskRunnable(
                private val task: Task,
                private val scanner: Scanner,
                private val printer: PrintWriter
        ) {
            fun run() {
                task.solve(scanner, printer)
            }
        }
    }

    @JvmStatic
    fun main(args: Array<String>) = TaskBuilder()
//            .useInputSource(BufferedInputStream(FileInputStream("area1.in")))
//            .useOutputSource(BufferedOutputStream(FileOutputStream("area1.out")))
            .useInputSource(System.`in`)
            .useOutputSource(System.out)
            .useScanner(FastScanner())
            .solveTask(TaskF())
            .run()

    class TaskA: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val numbers = Array(length) { scanner.nextInt() }

            var maxOnesCount = -1

            (0 until length) { i ->
                (i until length) { j ->
                    var currentCountOfOnes = 0
                    (0 until length) {
                        currentCountOfOnes += if((it in (i..j) && 1 - numbers[it] == 1) || (it !in (i..j) && numbers[it] == 1)) 1 else 0 }
                    maxOnesCount = max(maxOnesCount, currentCountOfOnes)
                }
            }

            printer.println(maxOnesCount)
        }

    }

    class TaskD: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextLong()
            (length until 2 * length) { printer.print("$it ") }
        }

    }

    class TaskE: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val lineLengths = Array(length) { scanner.nextInt() }
            lineLengths.sort()
            for(it in (2 until length))
                if(lineLengths[it-2] + lineLengths[it-1] > lineLengths[it]) {
                    printer.println("YES")
                    return
                }
            printer.println("NO")
        }

    }

    class TaskF: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val (start, check, delta) = scanner.nextLine()
                    .split(" ")
                    .map { it.toLong() }
            when {
                check < start -> printer.println("NO")
                delta == 0L && start == check -> printer.println("YES")
                (check - start) % delta == 0L -> printer.println("YES")
                else -> printer.println("NO")
            }
        }

    }

}


import java.io.*
import java.math.BigDecimal
import java.math.BigInteger
import java.util.StringTokenizer
import java.util.Stack
import java.util.TreeMap

object programkt {
    interface Scanner {
        fun changeInputStream(inputStream: InputStream)
        fun nextInt(): Int
        fun nextLong(): Long
        fun nextDouble(): Double
        fun nextChar(): Char
        fun nextString(): String
        fun nextLine(): String
        fun nextBigInteger(): BigInteger
        fun nextBigDecimal(): BigDecimal
    }

    abstract class Task {
        //KT Extensions
        fun <T : Comparable<T>> min(a: T, b: T) = if (a > b) b else a
        fun <T : Comparable<T>> max(a: T, b: T) = if (a < b) b else a
        fun abs(a: Int) = if (a > 0) a else -(a)
        fun abs(a: Long) = if (a > 0) a else -(a)
        fun abs(a: Float) = if (a > 0) a else -(a)
        fun abs(a: Double) = if (a > 0) a else -(a)
        operator fun <T> Iterable<T>.invoke(function: (it: T) -> Unit) { this.forEach(function) }
        private fun String.prefix(pi: Array<Int>): Array<Int> {
            pi[0] = 0
            (1 until this.length) {
                var j = pi[it - 1]
                while (j > 0 && this[it] != this[j]) {
                    j = pi[j - 1]
                }
                if(this[it] == this[j]) {
                    j++
                }
                pi[it] = j
            }
            return pi
        }
        private fun String.kmpFind(pattern: String): Int {
            val m = pattern.length
            val dfa = Array(256) { IntArray(m) }
            dfa[pattern[0].toInt()][0] = 1
            var x = 0
            var j = 1
            while (j < m) {
                for (c in 0 until 256) {
                    dfa[c][j] = dfa[c][x]        // Copy mismatch cases.
                }
                dfa[pattern[j].toInt()][j] = j + 1   // Set match case.
                x = dfa[pattern[j].toInt()][x]       // Update restart state.
                j++
            }

            val n = this.length
            var i: Int = 0
            j = 0
            while (i < n && j < m) {
                j = dfa[this[i].toInt()][j]
                i++
            }
            if (j == m) return i - m    // found
            return n                    // not found
        }
        fun fuckExceptions(invoker: () -> Unit) = try { invoker.invoke() } catch (_: Throwable) {}

        enum class EdgeType {
            DIRECTED,
            UNDIRECTED
        }
        data class Vertex<T: Comparable<T>>(
                val data: T
        ) {
            override fun toString(): String = "V:$data"
        }
        data class Edge<T:Comparable<T>>(
                var source: Vertex<T>,
                var destination: Vertex<T>,
                val weight: Double?
        )
        interface Graphable<T: Comparable<T>> {
            fun createVertex(data: T): Vertex<T>
            fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double? = 0.0)
            fun weight(source: Vertex<T>, destination: Vertex<T>): Double?
            fun edges(source: Vertex<T>): MutableList<Edge<T>>?
        }
        class AdjacencyList<T: Comparable<T>>: Graphable<T> {
            var adjacencyMap: MutableMap<Vertex<T>, MutableList<Edge<T>>> = mutableMapOf()

            private fun addDirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                adjacencyMap[source]?.add(Edge(source = source, destination = destination, weight = weight))
            }

            private fun addUndirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                addDirectedEdge(source, destination, weight)
                addDirectedEdge(destination, source, weight)
            }

            override fun createVertex(data: T): Vertex<T> {
                val vertex = Vertex(data = data)
                adjacencyMap[vertex] ?: run {
                    adjacencyMap[vertex] = mutableListOf()
                }
                return vertex
            }

            override fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double?) = when(type) {
                EdgeType.DIRECTED -> addDirectedEdge(source, destination, weight)
                EdgeType.UNDIRECTED -> addUndirectedEdge(source, destination, weight)
            }

            override fun weight(source: Vertex<T>, destination: Vertex<T>): Double? {
                adjacencyMap[source]?.forEach {
                    if(it.destination == destination) return it.weight
                }
                return null
            }

            override fun edges(source: Vertex<T>): MutableList<Edge<T>>? = adjacencyMap[source]

            override fun toString(): String {
                var result = ""
                for ((vertex, edges) in adjacencyMap) {
                    var edgeString = ""
                    for ((index, edge) in edges.withIndex()) {
                        edgeString += if (index != edges.count() - 1) "${edge.destination}, "
                        else "${edge.destination}"
                    }
                    result += "$vertex ---> [ $edgeString ] \n"
                }
                return result
            }

            fun depthFirstSearch(start: Vertex<T>, end: Vertex<T>): Stack<Vertex<T>> {
                val visited: HashSet<Vertex<T>> = hashSetOf()
                val stack: Stack<Vertex<T>> = Stack()
                stack.push(start)
                visited.add(start)

                var currentVertex = stack.peek()
                loop@while (currentVertex != null && currentVertex != end) {
                    val neighbors = edges(currentVertex)
                    if(neighbors != null && neighbors.count() > 0) {
                        for(edge in neighbors) {
                            if(!visited.contains(edge.destination)) {
                                visited.add(edge.destination)
                                stack.push(edge.destination)
                                currentVertex = stack.peek()
                                continue@loop
                            }
                        }
                    } else {
                        stack.pop()
                        currentVertex = stack.peek()
                        continue
                    }

                    stack.pop()
                    currentVertex = stack.peek()
                }

                return stack
            }

            fun breadthFirstSearch() {

            }

            fun floydWarshallAlgorythm(): Pair<Array<DoubleArray>, Array<IntArray>> {
                val nVertices = this.adjacencyMap.size

                val weights = Array(nVertices) { Array(nVertices-1) { 0.0 } }
                this.adjacencyMap
                        .asSequence()
                        .map { it.value }
                        .withIndex()
                        .forEach { (index, weightsOfVertex) ->
                            weightsOfVertex.asSequence()
                                    .withIndex()
                                    .forEach { (weightIndex, weight) ->
                                        weights[index][weightIndex] = weight.weight!!
                                    }
                        }

                val dist = Array(nVertices) { DoubleArray(nVertices) { Double.POSITIVE_INFINITY } }
                for (w in weights) dist[(w[0] - 1).toInt()][(w[1] - 1).toInt()] = w[2]
                val next = Array(nVertices) { IntArray(nVertices) }
                for (i in 0 until next.size) {
                    for (j in 0 until next.size) {
                        if (i != j) next[i][j] = j + 1
                    }
                }
                for (k in 0 until nVertices) {
                    for (i in 0 until nVertices) {
                        for (j in 0 until nVertices) {
                            if (dist[i][k] + dist[k][j] < dist[i][j]) {
                                dist[i][j] = dist[i][k] + dist[k][j]
                                next[i][j] = next[i][k]
                            }
                        }
                    }
                }
                return dist to next
            }
        }

        fun <T: Comparable<T>> TreeMap<T, Array<Double>>.toAdjacencyList(type: EdgeType): AdjacencyList<T> {
            val list = AdjacencyList<T>()

            this.keys.forEach { list.createVertex(it) }
            this.entries
                    .asSequence()
                    .withIndex()
                    .forEach { (x, edge) ->
                        val vertex = list.createVertex(edge.key)
                        edge.value
                                .asSequence()
                                .withIndex()
                                .forEach { (y, weight) ->
                                    if(weight != .0 && y != x)
                                        list.add(type, vertex, list.createVertex(this.keys.elementAt(y)), weight)
                                }
                    }
            return list
        }

        open class Point<X: Comparable<X>, Y: Comparable<Y>>(open var x: X, open var y: Y) {
            operator fun component1() = x
            operator fun component2() = y
            override fun equals(other: Any?): Boolean = when {
                other == null -> false
                other !is Point<*, *> -> false
                other.x != this.x -> false
                other.y != this.y -> false
                else -> true
            }
        }

        class IntPoint(override var x: Int, override var y: Int): Point<Int, Int>(x, y) {
            operator fun plus(point: IntPoint) = IntPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: IntPoint) = IntPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: IntPoint) = IntPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: IntPoint) = IntPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Int) = IntPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Int) = IntPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Int) = IntPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Int) = IntPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: IntPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        class LongPoint(override var x: Long, override var y: Long): Point<Long, Long>(x, y) {
            constructor(x: Int, y: Int): this(x.toLong(), y.toLong())

            operator fun plus(point: LongPoint) = LongPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: LongPoint) = LongPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: LongPoint) = LongPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: LongPoint) = LongPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Long) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Long) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Long) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Long) = LongPoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = LongPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: LongPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        open class DoublePoint(override var x: Double, override var y: Double): Point<Double, Double>(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            operator fun plus(point: DoublePoint) = DoublePoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: DoublePoint) = DoublePoint(this.x - point.x, this.y - point.y)
            operator fun div(point: DoublePoint) = DoublePoint(this.x / point.x, this.y / point.y)
            operator fun times(point: DoublePoint) = DoublePoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Double) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Long) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Double) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Long) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Double) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Long) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Double) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Long) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = DoublePoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: DoublePoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)))
            fun polarAngle(): Double {
                val minPolarAngle = Math.atan2(y, x)
                return if(minPolarAngle < 0) minPolarAngle + 2 * Math.PI else minPolarAngle
            }
        }
        class Vector(x: Double, y: Double): DoublePoint(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            fun length() = Math.sqrt(x*x + y*y)
            fun angleTo(vector: Vector): Double {
                val temp = this * vector
                return Math.acos((temp.x + temp.y) / this.length() / vector.length())
            }
        }
        //End KT Extensions

        abstract fun solve(scanner: Scanner, printer: PrintWriter)
    }

    class FastScanner: Scanner {
        var inputStream: InputStream? = null
        override fun changeInputStream(inputStream: InputStream) {
            this.inputStream = inputStream
            this.bufferedReader = BufferedReader(InputStreamReader(inputStream))
        }

        private lateinit var bufferedReader: BufferedReader
        private var stringTokenizer: StringTokenizer? = null

        private fun nextToken(): String? {
            while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())
                stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)
            return stringTokenizer!!.nextToken()
        }

        override fun nextInt() = nextToken()!!.toInt()
        override fun nextLong() = nextToken()!!.toLong()
        override fun nextDouble() = nextToken()!!.toDouble()
        override fun nextChar() = bufferedReader.read().toChar()
        override fun nextString() = nextToken()!!
        override fun nextLine() = bufferedReader.readLine()!!
        override fun nextBigInteger() = BigInteger(nextToken()!!)
        override fun nextBigDecimal() = BigDecimal(nextToken()!!)
    }

    class TaskBuilder {
        private var task: Task? = null
        private var inputStream: InputStream? = null
        private var outputStream: OutputStream? = null
        private var scanner: Scanner? = null

        fun useInputSource(inputStream: InputStream): TaskBuilder {
            this.inputStream = inputStream
            return this
        }

        fun useOutputSource(outputStream: OutputStream): TaskBuilder {
            this.outputStream = outputStream
            return this
        }

        fun useInputFile(inputFileName: String): TaskBuilder {
            this.inputStream = FileInputStream(File(inputFileName))
            return this
        }

        fun useOutputFile(outputFileName: String): TaskBuilder {
            this.outputStream = FileOutputStream(File(outputFileName))
            return this
        }

        fun useScanner(scanner: Scanner): TaskBuilder {
            this.scanner = scanner
            return this
        }

        fun solveTask(task: Task): TaskBuilder {
            this.task = task
            return this
        }

        fun run() {
            when {
                task == null -> throw NullPointerException("Task cannot be null!")
                inputStream == null -> throw NullPointerException("Input cannot be null!")
                outputStream == null -> throw NullPointerException("Output cannot be null!")
                scanner == null -> throw NullPointerException("Scanner cannot be null!")
            }
            scanner!!.changeInputStream(inputStream!!)
            val printer = PrintWriter(outputStream)
            TaskRunnable(task!!, scanner!!, printer).run()

            inputStream!!.close()
            printer.close()
        }

        class TaskRunnable(
                private val task: Task,
                private val scanner: Scanner,
                private val printer: PrintWriter
        ) {
            fun run() {
                task.solve(scanner, printer)
            }
        }
    }

    @JvmStatic
    fun main(args: Array<String>) = TaskBuilder()
//            .useInputSource(BufferedInputStream(FileInputStream("area1.in")))
//            .useOutputSource(BufferedOutputStream(FileOutputStream("area1.out")))
            .useInputSource(System.`in`)
            .useOutputSource(System.out)
            .useScanner(FastScanner())
            .solveTask(TaskF())
            .run()

    class TaskA: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val numbers = Array(length) { scanner.nextInt() }

            var maxOnesCount = -1

            (0 until length) { i ->
                (i until length) { j ->
                    var currentCountOfOnes = 0
                    (0 until length) {
                        currentCountOfOnes += if((it in (i..j) && 1 - numbers[it] == 1) || (it !in (i..j) && numbers[it] == 1)) 1 else 0 }
                    maxOnesCount = max(maxOnesCount, currentCountOfOnes)
                }
            }

            printer.println(maxOnesCount)
        }

    }

    class TaskD: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextLong()
            (length until 2 * length) { printer.print("$it ") }
        }

    }

    class TaskE: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val lineLengths = Array(length) { scanner.nextInt() }
            lineLengths.sort()
            for(it in (2 until length))
                if(lineLengths[it-2] + lineLengths[it-1] > lineLengths[it]) {
                    printer.println("YES")
                    return
                }
            printer.println("NO")
        }

    }

    class TaskF: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val (start, check, delta) = scanner.nextLine()
                    .split(" ")
                    .map { it.toLong() }
            when {
                check < start && delta > 0 -> printer.println("NO")
                check > start && delta < 0 -> printer.println("NO")
                delta == 0L && start == check -> printer.println("YES")
                (check - start) % delta == 0L -> printer.println("YES")
                else -> printer.println("NO")
            }
        }

    }

}


import java.util.*

fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    val initial = reader.nextLong()
    val desired = reader.nextLong()
    val seq = reader.nextLong()
    if (desired - initial == 0L) {
        println("YES")
        return
    }
    if ((desired - initial) % seq == 0L && ((desired - initial) / seq) > 0)
        println("YES")
    else println("NO")
}


import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*

val n = 0
val m = 0
fun valid(i: Int, j: Int): Boolean {
    return i in 0 until n && j in 0 until m
}

fun sumRow(arr: IntArray): Int {
    var sum = 0
    for (element in arr) sum += element
    return sum
}

fun sumCol(twoDArr: Array<IntArray>, colNumber: Int): Int {
    var sum = 0
    for (element in twoDArr) {
        sum += element[colNumber]
    }
    return sum
}

@JvmField
val INPUT = System.`in`
@JvmField
val OUTPUT = System.out

@JvmField
val _reader = INPUT.bufferedReader()

fun readLine(): String? = _reader.readLine()!!
fun readLn() = _reader.readLine()!!
@JvmField
var _tokenizer: StringTokenizer = StringTokenizer("")

fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}

fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }.toMutableList().toLongArray()

@JvmField
val _writer = PrintWriter(OUTPUT, false)

inline fun output(block: PrintWriter.() -> Unit) {
    _writer.apply(block).flush()
}

fun printArr(arr: IntArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun printArr(arr: LongArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun main() {
    val (a, b, c) = readLongs(3)
    if (a == b) println("YES")
    else if (a < b && c > 0) if (c == 1L) println("YES") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else if (a > b && c < 0) if (c == -1L) println("NO") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else println("NO")
    //TODO("KYS")
}


fun main() {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val (c, d) = readLine()!!.split(" ").map { it.toInt() }
    when {
        a % 2 == 0 && b % 2 == 0 && c % 2 == 0 && d % 2 != 0 -> print(-1)
        c % 2 == 0 && d % 2 == 0 && a % 2 == 0 && b % 2 != 0 -> print(-1)
        else -> {
            var first = b
            var second = d
            while (first != second) {
                if (first < second) first += a else second += c
            }
            print(first)
        }
    }
}


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

tailrec fun gcd(a: Int, b: Int): Int {
    if (a != 0 && b != 0) {
        if (a > b) return gcd(a % b, b)
        else return gcd(b % a, a)
    }

    return a + b
}

fun gcde(a: Int, b: Int): Triple<Int, Int, Int> {
    if (a == 0) {
        return Triple(b, 0, 1)
    }

    val (d, x1, y1) = gcde(b % a, a)

    return Triple(d, y1 - (b / a) * x1, x1)
}

fun DataReader.solve(out: PrintWriter) {
    val b = nextInt()
    val a = nextInt()
    val d = nextInt()
    val c = nextInt()

    val q = c - a
    val (g) = gcde(b, -d)

    if (q % g != 0) {
        out.println(-1)
        return
    }

    for (i in 1..100000000) {
        val w = a + i * b - c

        if (w >= 0 && w % d == 0) {
            out.println(w + c)
            return
        }
    }

//
//    val p = q / g
//
//    val (g1, x, y) = gcde(b / g, -d / g)
//
//    val (xr, yr) = x * p to y * p

    throw RuntimeException(":(")
}

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 readLongArray(n: Int) : LongArray {
        val result = LongArray(n)
        result.indices.forEach { i -> result[i] = nextLong() }
        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()
}


import ds.*
import nt.*
import java.io.*
import java.util.*
import java.math.*

//val inp = BufferedReader(FileReader ( "input.txt" ) )
val inp = BufferedReader(InputStreamReader(System.`in`))

fun solve() : Int {
	val a = ( inp.readLine() ?: return 1 ).split(" ").map{ it.toInt() }
	val b = ( inp.readLine() ?: return 1 ).split(" ").map{ it.toInt() }
	var curA = a[1]
	var curB = b[1]
	for ( i in 1..1000000 ) {
		if ( curA == curB ) {
			println ( "" + curA )
			return 0
		}
		if ( curA < curB ) curA += a[0]
		else curB += b[0]
	}
	println ( "-1" )
	return 0
}

fun main ( args : Array<String> ) {
	while (solve()==0);
}


fun main(args: Array<String>) {
        var n = readLine()!!.toInt()
        var N = 0
        for (i in n downTo 0){
            if (n % 2 == 0){
                N++
                n /= 2
            }
        }
    print(N)
    }


fun main(args: Array<String>) {
        var n = readLine()!!.toInt()
        var N = 0
        for (i in n downTo 1){
            if (n % 2 == 1)
                N++
                n /= 2
        }
    print(N)
    }


//package tasks.t579a

import kotlin.math.*

fun main(args: Array<String>) {
    readLine()!!.toDouble().let {
        val res = it - 2.0.pow(log2(it).toInt()) + 1
        println(res.toInt())
    }
}


import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val x = br.readLine().toInt()
    val pow = findClosestPow(x)
    val rem = x - pow
    println(1 + rem)
}

fun findClosestPow (x: Int): Int{
    tailrec fun go (i: Int, acc: Int): Int =
        if (acc == x) acc
        else if (acc > x) acc/2
        else go(i + 1, acc*2)
    return go(0, 1)
}


fun main() {
    println(readLine()!!.count { it == '1' })
}


//package codeforces

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val In = BufferedReader(InputStreamReader(System.`in`))
    val n = In.readLine()!!.toInt()
    if(n<1)
        println(0)

    var res = 1
    for (i in 0..8*Integer.BYTES) {
        var current = 1 shl i
        if(current > n)
            break
        res = i
    }
    println((n - Math.pow(2.0, res.toDouble()) + 1).toInt())
}


fun main()
{
    // ismail moussi Test Kotlin kotlin
    val num=readLine()!!.toInt()
    var count=1
    var count2=0
    var range=0
    while(count<num-1)
    {
        count*=2
    }
        range=num-count
        println(range+1)
}


import kotlin.contracts.contract
import kotlin.math.max
import kotlin.math.min

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of Longs

fun main() {
//    var (a1, a2, k1, k2, n) = listOf(3, 1, 6, 7, 0)
    var a1 = readInt()
    var a2 = readInt()
    var k1 = readInt()
    var k2 = readInt()
    var n = readInt()

    var max1 = min(a1, n / k1)
    var max2 = min(a2, n / k2)

    var maxK1 = max1 * k1
    var maxK2 = max2 * k2
    var ansMax = 0

    var nmax = n
    if (max1 > max2) {
        ansMax = max1

        nmax -= (max1 * k1)
        val max22 = min(a2, nmax / k2)
        ansMax += max22
    } else {
        ansMax = max2

        nmax -= (max2 * k2)
        val max22 = min(a1, nmax / k1)
        ansMax += max22
    }

    var ansMin = 0
//    var nMin = n
//    if (k1 > k2) {
//        var k = min(a1, nMin / k1)
//        ansMin += k
//        nMin -= k * k1
//
//        k = min(a2, nMin / k2)
//        ansMin += k
//    } else {
//        var k = min(a2, nMin / k2)
//        ansMin += k
//        nMin -= k * k2
//
//        k = min(a1, nMin / k1)
//        ansMin += k
//    }

//    var kart = (n / (a1 + a2))
//    var t1 = kart
//    var t2 = kart
//
//    if (k1 < t1) {
//        t2 += t1 - k1
//    } else {
//        if (k2 < t2) {
//            t1 += t2 - k2
//        }
//    }
//
//    if (t1 >= k1) {
//        ansMin += a1
//    }
//    if (t2 >= k2) {
//        ansMin += a2
//    }

    var m = ArrayList<Int>()
    for (i in 1..a1) m.add(k1)
    for (i in 1..a2) m.add(k2)

    var key = false
    while (!key) {
        key = true
        for (i in 0 until m.size) {
            val k = m[i]
            if (k <= 1) continue
            n--
            if (n < 1) {
                key = true
                break
            }
            m[i]--
            key = false
        }
    }

    ansMin = max(0,min(n, a1 + a2))

    print("$ansMin $ansMax")
}


package my.demo

import kotlin.text.*
fun main(){
    val x = readLine()
    var cnt: Int = 0
    var buang: Int = 0
    for(i in x.toString()){
        if(i=='a')
            cnt += 1
    }
    var n :Int = x.toString().length
    var half: Double = n/2.0
    while(half>=cnt)
    {
        buang+=1
        half=(n-buang)/2.0
    }
    var ans:Int =n-buang
    println(ans)
    return
}


fun main() {
    val line = readLine()!!.toCharArray()
    val n = line.size
    var a = 0;
    for (i in 0 until n)
        if (line[i] == 'a')
            a++

    if (a > n / 2)
        print(n)
    else
        print(++a)

}


fun main() {
    val input = Scanner(System.`in`)
    while (input.hasNext()) {
        val s = input.next()
        val len = s.length
        var res = 0
        for (elem in s.toCharArray()) {
            if (elem == 'a') {
                res++
            }
        }
        res *= 2
        if (res > len) {
            println(len)
        } else {
            println(len - res)
        }
    }
    input.close()
}


import java.util.*

fun main() {
    val input = Scanner(System.`in`)
    while (input.hasNext()) {
        val s = input.next()
        val len = s.length
        var res = 0
        for (elem in s.toCharArray()) {
            if (elem == 'a') {
                res++
            }
        }
        res *= 2
        if (res > len) {
            println(len)
        } else {
            println(len - res)
        }
    }
    input.close()
}


fun main() {
    val s = readLn()

    val ans = maxOf(s.length, 2 * s.count { it == 'a' } - 1)

    println(ans)
}

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readDoubles() = readStrings().map { it.toDouble() }
fun readLongs() = readStrings().map { it.toLong() }

class Output {
    private val sb = StringBuilder()
    fun print(o: Any?) { sb.append(o) }
    fun println(o: Any?) { sb.append(o).append('\n') }
    @JvmName("_print") fun Any?.print() = print(this)
    @JvmName("_println") fun Any?.println() = println(this)
    fun nowPrint() { kotlin.io.print(sb) }
}
inline fun output(block: Output.()->Unit)
    { Output().apply(block).nowPrint() }


fun suma(s:String):Int{
    var count=0
    for(i in s.indices)
    {
        if(s[i]=='a')
        {
            count++
        }
    }
    return count
}
fun main()
{
    val s :String= readLine()!!
    var count=0
   //var siize=(s.length/2)+1
    var i=0
    var test=0
    var su=suma(s)
    if(s.length==1)
    {
            print(1)
        return
    }
    if(suma(s)>s.length/2)
    {
        print(s.length)
        return
    }else
    {
      while(su<(s.length/2))
      {
          if(s[test]!='a')
          {
             su++
          }
      }
    }
    print(su)
}


fun main(args: Array<String>) {
    val x = readLine()!!
    var aScore = 0
    for(i in 0 until x.length){
    when{
            (x[i] == 'a') ->aScore++
        }
    }
    if(aScore > x.length-aScore) println(x.length) else println(aScore+1)
}


private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readDouble() = readLn().toDouble()
private fun readStrings() = readLn().split(' ')
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main() {
    val s = readLn()
    val cntA = s.count { it == 'a' }
    println(if (cntA > s.length / 2) s.length else if (cntA == 1) 1 else cntA + 1)
}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val m = readLine()!!.toInt()
    var t = 0
    var maks = 0
    for (i in 1..n)
    {
        val a = readLine()!!.toInt()
        t+=a
        if (a > maks)
            maks = a
    }
    var mini = (t+m)/n
    if (mini * n < t+m)
        mini++
    println("$mini ${maks+m}")
}


fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val a = mutableListOf<Int>()
    while (scanner.hasNextInt()) {
        a.add(scanner.nextInt())
    }

    a.sortByDescending { it }
    val firstValue = a[0] + m
    for (i in 0 until m) {
        a.sortBy { it }
        a[0]++
    }
    print(a[0])
    print(" ")
    print(firstValue)
}


import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val a = mutableListOf<Int>()
    while (scanner.hasNextInt()) {
        a.add(scanner.nextInt())
    }

    a.sortByDescending { it }
    val firstValue = a[0] + m
    for (i in 0 until m) {
        a.sortBy { it }
        a[0]++
    }
    print(a[0])
    print(" ")
    print(firstValue)
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.*
fun main(args: Array<String>) {

    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val str = scanner.next()
    if (str.reversed() == scanner.next())
        println("YES")
    else
        println("NO")

}

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()
    }
}

fun IntArray.print() {
    println(Arrays.toString(this))
}

//class Pair(var a: Int, var b: Int): Comparable<Pair> {
//    override fun compareTo(other: Pair): Int {
//        return b - a - other.b + other.a
//    }
//}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val s1 = r.readLine()!!
    val s2 = r.readLine()!!
    val len = s1.length
    var correct = true
    (0..len-1).forEach {
        if (s1[it]!=s2[len-1-it]) correct = false
    }
    println(if (correct) "YES" else "NO")
}


fun main(args: Array<String>) {
    var S = readLine()!!
    var s = readLine()!!
    var n = s.length-1
    var c = true
    for (i in 0..n){
        if (S[i] == s[n-i])
            c = true
        else
            c = false
    }
    if (c == true)
        print("YES")
    else
        print("NO")
}


fun main(args: Array<String>) {
    var S = readLine()!!
    var s = readLine()!!
    var n = s.length-1
    var c = 0
    for (i in 0..n){
        if (S[i] == s[n-i])
            c ++
        else
            c --
    }
    if (c == n+1)
        print("YES")
    else
        print("NO")
}


// https://codeforces.com/problemset/problem/41/A

fun main(args: Array<String>) {
    val word = readLn()
    val translation = readLn()

    var correct = true
    for ((index, value) in word.withIndex()) {
        if (value != translation[translation.length - 1 - index]) {
            correct = false
        }
    }

    if (correct) {
        print("YES")
    } else {
        print("NO")
    }
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings(del: String = " ") = readLn().split(del) // list of strings
private fun readInts(del: String = " ") = readStrings(del).map { it.toInt() } // list of ints


import java.util.*
fun main() {
    val sc = Scanner(System.`in`)
    val s = sc.nextLine()
    if(s==s.reversed()) print("YES") else print("NO")
}


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

    var isTrueTranslate = true

    for(i in 0.. word.lastIndex){
        if (word[i] != translateWord[translateWord.lastIndex - i]){
            isTrueTranslate =  false
        }
    }

    if (isTrueTranslate){
        print("YES")
    } else {
        print("NO")
    }
}


private fun readLn() = readLine()!!
private fun readString() = readLn().trim()
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private val regSpace = "\\s+".toRegex()
private fun readSomeInts(): List<Int> {
    return readLn().trim().split(regSpace).map { it.toInt() }
}
private fun readSomeLongs(): List<Long> {
    return readLn().trim().split(regSpace).map { it.toLong() }
}

data class Point(val row: Int, val col: Int)

fun main() {
    val (n, m) = readSomeInts()

    fun neighbors(p: Point): List<Point> {
        val acc = mutableListOf<Point>()
        if (p.row > 0) {
            acc.add(Point(p.row - 1, p.col))
        }
        if (p.col > 0) {
            acc.add(Point(p.row, p.col - 1))
        }
        if (p.col < m - 1) {
            acc.add(Point(p.row, p.col + 1))
        }
        if (p.row < n - 1) {
            acc.add(Point(p.row + 1, p.col))
        }
        return acc
    }

    val field = mutableListOf<String>().apply {
        repeat(n) {
            val s = readString()
            this.add(s)
        }
    }.toList()

    fun hasWolf(p: Point) = field[p.row][p.col] == 'W'

    val wolfNotHangry = Array<BooleanArray>(n) { BooleanArray(m) }

    var countEatenPigs = 0
    for (i in 0 until n) {
        for (j in 0 until m) {
            if (field[i][j] == 'P') {
                val pigPt = Point(i, j)
                val anyWolf = neighbors(pigPt)
                        .firstOrNull { pt -> hasWolf(pt) && wolfNotHangry[pt.row][pt.col] }
                if (anyWolf != null) {
                    wolfNotHangry[anyWolf.row][anyWolf.col] = true
                    countEatenPigs++
                }
            }
        }
    }
    println(countEatenPigs)
}


fun main() {
    val table = Table()

    val notEatenPig: (Cell) -> Boolean = { it is PigCell && !it.eaten }

    // eat variant pig
    fun eatPig(nearbyCount: Int): Int {
        println("eat for $nearbyCount pigs")
        var eatCount = 0
        table.forEachIndexed { x, y, cell ->
            if (cell is WolfeCell && !cell.eat) {
                val nearbyPigs = table.nearby(x, y, notEatenPig)
                if (nearbyPigs.size == nearbyCount) {
                    cell.eat = true
                    (nearbyPigs.first() as PigCell).eaten = true
                    eatCount += 1
                    println("wolf on ($x, $y) eat pig")
                }
            }
        }
        return eatCount
    }

    println((1..4).fold(0) { acc, count -> acc + eatPig(count) })
}

class Table {
    private val matrix: List<List<Cell>>
    private val n: Int
    private val m: Int

    init {
        readLine()!!.split(" ")
            .map(String::toInt)
            .also {
                n = it[0]
                m = it[1]
            }

        matrix = (0 until n).map {
            readLine()!!.toCharArray().take(m)
                .map {
                    when (it) {
                        'P' -> PigCell()
                        'W' -> WolfeCell()
                        '.' -> EmptyCell
                        else -> throw IllegalArgumentException("Unknown animal")
                    }
                }
        }
    }

    fun forEachIndexed(action: (x: Int, y: Int, cell: Cell) -> Unit) {
        matrix.forEachIndexed { i, row ->
            row.forEachIndexed { j, cell -> action(i, j, cell) }
        }
    }

    private fun inRange(x: Int, y: Int) = x in 0 until n && y in 0 until m

    fun nearby(x: Int, y: Int, predicate: (Cell) -> Boolean): List<Cell> {
        return listOf(
            Pair(x - 1, y),  // left
            Pair(x + 1, y),  // right
            Pair(x, y - 1),  // top
            Pair(x, y + 1)   // bottom
        )
            .filter { (x, y) -> inRange(x, y) }
            .map { (x, y) -> matrix[x][y] }
            .filter(predicate)
    }
}

sealed class Cell

data class PigCell(
    var eaten: Boolean = false
) : Cell()

data class WolfeCell(
    var eat: Boolean = false
) : Cell()

object EmptyCell : Cell()


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

object program {
  @JvmStatic fun main(args: Array<String>) {
    if (args.size == 1)
      System.setIn(FileInputStream(args[0]))
    val sc = Scanner(System.`in`)
    sc.nextLine()
    val all = sc.nextLine()
    var eights = all.filter { it == '8' }.count()
    var others = all.length - eights
    var numbers = 0
    while (eights > 0) {
      eights--
      IntRange(1, 10).forEach {
        if (others > 0)
          others--
        else
          eights--
      }
      if (numbers < 0 || eights < 0)
        break
      numbers++
    }
    println(numbers)
  }
}


fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var digits = readLine()!!.count {it == '8'}
    println(minOf(n / 8, digits))
}


fun main() {
    val numToLine = mapOf('0' to "O-|-OOOO", '1' to "O-|O-OOO", '2' to "O-|OO-OO", '3' to "O-|OOO-O", '4' to "O-|OOOO-",
        '5' to "-O|-OOOO", '6' to "-O|O-OOO", '7' to "-O|OO-OO", '6' to "-O|OOO-O", '6' to "-O|OOOO-")
    for (c in readLine()!!.reversed()) println(numToLine[c]!!)
}


package challenge.codeb

import java.io.File
import java.io.IOException
import java.util.StringTokenizer
import java.io.InputStreamReader
import java.io.BufferedReader

val debugCode = false

fun debugCode(str: String) {
    if (debugCode) {
        println(str)
    }
}

fun solve(arr: IntArray): Int {
    arr.sort()
    var result = 0
    var i = 0
    while (i < arr.size) {
        result += Math.abs(arr[i]- arr[i+1])
        i += 2
    }
    return result
}

fun main(args: Array<String>) {
    val scan = FastReader("1.txt")
    val n = scan.nextInt()
    val arr = IntArray(n, {scan.nextInt()} )
    println(solve(arr))
}

class FastReader(val input: String) {
    var br: BufferedReader
    var st: StringTokenizer? = null

    init {
        if (!debugCode) {
            br = BufferedReader(InputStreamReader(System.`in`))
        } else {
            br = BufferedReader(InputStreamReader(File(input).inputStream()))
        }
    }

    operator fun next(): String {
        while (st == null || !st!!.hasMoreElements()) {
            try {
                st = StringTokenizer(br.readLine())
            } catch (e: IOException) {
                e.printStackTrace()
            }

        }
        return st!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = br.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


import java.utils.Scanner

 fun main(args:Array<String>) {
  var sc = Scanner(System.`in`)
  var n = sc.nextInt()
  var m = sc.nextInt()
  var result = 0
  while (m > n)
  {
    if (m % 2 == 0)
    {
      m = m / 2
      result++
    }
    else
    {
      m++
      result++
    }
  }
  if (n > m)
  {
    result += Math.abs(n - m)
  }
  println(result)
}


import java.util.ArrayDeque

private fun nextLine() = readLine()!!
private fun nextInt() = nextLine().toInt()
private fun nextToks() = nextLine().split(" ")
private fun nextInts() = nextToks().map{it.toInt()}

data class State(val num: Int, val cost: Int)

fun main() {
    val (n, m) = nextInts()
    val queue = ArrayDeque<State>()
    queue.add(State(n, 0))
    while (true) {
        val (num, cost) = queue.remove()
        if (num == m) {
            println(cost)
            break
        }
        queue.add(State(num * 2, cost + 1))
        if (num > 0) queue.add(State(num - 1, cost + 1))
    }
}


import kotlin.math.*

private fun nextLine() = readLine()!!
private fun nextInt() = nextLine().toInt()
private fun nextToks() = nextLine().split(" ")
private fun nextInts() = nextToks().map{it.toInt()}

data class Result(val ans: Int, val ok: Boolean, val newBound: Int)

fun h(x: Int, m: Int): Int {
    if (x >= m) return x - m
    val log2r = log2(m.toDouble() / x)
    return (2 * ceil(log2r) - floor(log2r)).roundToInt()
}

fun ida(x: Int, m: Int, cost: Int, bound: Int): Result {
    val fx = cost + h(x, m)
    if (fx > bound) return Result(-1, false, fx)
    if (x == m) return Result(cost, true, -1)
    val (redAns, redFound, redBound) = ida(x*2, m, cost+1, bound)
    if (x == 1) return Result(redAns, redFound, redBound)
    val (blueAns, blueFound, blueBound) = ida(x-1, m, cost+1, bound)
    return when {
        !redFound && !blueFound -> Result(-1, false, minOf(redBound, blueBound))
        !redFound -> Result(blueAns, true, -1)
        !blueFound -> Result(redAns, true, -1)
        else -> Result(minOf(redAns, blueAns), true, -1)
    }
}

fun main() {
    val (n, m) = nextInts()
    var bound = h(n,m)
    while (true) {
        val (ans, found, newBound) = ida(n, m, 0, bound)
        if (found) {
            println(ans)
            break
        }
        bound = newBound
    }
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val que: Queue<Pair<Int, Int>> = ArrayDeque()
    que.add(n to 0)
    val visited = Array(100000) { false }
    visited[n] = true
    while (que.count() > 0) {
        val (t, step) = que.poll()
        if (t == m) {
            println(step)
            return
        }
        if (t < m) {
            que.add(2 * t to step + 1)
            visited[2 * t] = true
        }
        if (t > 1) {
            que.add(t - 1 to step + 1)
            visited[t - 1] = true
        }
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val que: Queue<Pair<Int, Int>> = ArrayDeque()
    que.add(n to 0)
    val visited = Array(100000) { false }
    visited[n] = true
    while (que.count() > 0) {
        val (t, step) = que.poll()
        if (t == m) {
            println(step)
            return
        }
        if (t < m) {
            que.add(2 * t to step + 1)
            visited[2 * t] = true
        }
        que.add(t - 1 to step + 1)
        visited[t - 1] = true
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


fun main(args: Array<String>)
{
    var count:Int = 0
    var n:Int = readLine()!!.toInt()
    var m:Int = readLine()!!.toInt()
    var temp:Int = n
    if(n >= m) {
        println(message = n - m)
        return
    }
    while(temp != m)
    {
        when {
            (temp*2)-m >= 2 -> temp--
            temp-m == 1 -> temp--
            else -> temp *= 2
        }
        count++
    }
    println(message = count)
}


// 7/9/2020 2:44 PM

// https://codeforces.com/problemset/problem/520/B

//package p520

import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val (n, m) = readInts()
    print(getMinimumClicks(n, m))
}

class ClickSequence(val currentDisplay: Int, val target: Int, val currentClicks: Int) : Comparable<ClickSequence> {
    private val predictedClicks = getNaiveClicks(currentDisplay, target) + currentClicks

    override fun compareTo(other: ClickSequence): Int {
        return this.predictedClicks.compareTo(other.predictedClicks)
    }
}

fun getNaiveClicks(currentDisplay: Int, target: Int) : Int {
    if (currentDisplay >= target)
        return currentDisplay - target
    else {
        return 1 + getNaiveClicks(2*currentDisplay, target)
    }
}

fun getMinimumClicks(displayNumber: Int, targetNumber: Int) : Int {
    if (displayNumber >= targetNumber)
        return displayNumber - targetNumber

    val pq = PriorityQueue<ClickSequence>()
    pq.add(ClickSequence(displayNumber - 1, targetNumber, 1))
    pq.add(ClickSequence(displayNumber * 2, targetNumber, 1))

    var curElement = pq.poll()
    while (curElement.currentDisplay != curElement.target) {
        pq.add(ClickSequence(curElement.currentDisplay - 1, curElement.target, curElement.currentClicks + 1))
        pq.add(ClickSequence(curElement.currentDisplay * 2, curElement.target, curElement.currentClicks + 1))
        curElement = pq.poll()
    }

    return curElement.currentClicks
}


import kotlin.math.min

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }
    println(find(n, m, 0))
}

var best = Long.MAX_VALUE

fun find(n : Long, m : Long, steps : Int) : Long{
    if (m <= n){
        best = min(steps + n - m, best)
        return best
    }

    if (steps < best){
        return min(find( n * 2, m, steps + 1), find(n - 1, m, steps + 1) )
    }else return best
}


import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.LinkedHashSet
import kotlin.math.abs

fun main(){
    var scanner = Scanner(System.`in`)
    var n = scanner.nextInt()
    var m = scanner.nextInt()
    var counts=0
    while(n<m){
        if(abs(((n-1)*2)-m) > (abs(n*2)-m) && n>2){
            n = (n-1)*2
            counts+=2
        }
        else if((n-1)*2-m == 0){
            n = (n-1)*2
            counts+=2
        }
        else if((n-1)*2 < n*2 && n>2 ){
            n--
            counts++
        }
        else{
            n *= 2
            counts +=1
        }
    }
    if(n>=m){
        while(n!=m){
            n--
            counts++
        }
    }
    println(counts)

}