import java.lang.Long.max
import java.lang.Long.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.toLong() } // list of ints

fun main() {
    val q = readInt()

    repeat(q) {
        val (a, b, m) = readInts()
        var (l, r) = Pair(a, a)
        val segs = mutableListOf<Pair<Long, Long>>()
        while (r < b) {
            if (l > a)
                segs.add(Pair(l, r))
            l = a
            r = a
            for (x in segs) {
                l += x.first
                r += x.second
            }
            l += 1
            r += m
        }
        if (l > b)
            print("-1\n")
        else {
            fun f(x: Int) = 1L shl x-1

            val ans = mutableListOf(a)
            var cur = l
            var sm = a
            for ((i, x) in segs.withIndex()) {
                var temp = sm + 1
                for (i in 0 until min(m-1, 1e9.toLong()).toInt()) {
                    if (cur + f(segs.size-i) <= b) {
                        temp++
                        cur += f(segs.size-i)
                    }
                    else
                        break
                }
                ans.add(temp)
                sm += temp
            }
            ans.add(b)
            print("" + ans.size + " " + ans.joinToString(" ") + "\n")
        }
    }
}


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.toLong() } // list of ints

fun main() {
    val q = readInt()

    repeat(q) {
        val (a, b, m) = readInts()
        var (l, r) = Pair(a, a)
        val segs = mutableListOf<Pair<Long, Long>>()
        while (r < b) {
            segs.add(Pair(l, r))
            l = 0
            r = 0;
            for (x in segs) {
                l += x.first
                r += x.second
            }
            l += 1
            r += m
        }
        if (l > b)
            print("-1\n")
        else {
            val ans = mutableListOf(b)
            segs.reverse()
            for (x in segs) {
                ans.add(x.second)
            }
            ans.reverse()
            print("" + ans.size + " " + ans.joinToString(" ") + "\n")
        }
    }
}


fun main(args: Array<String>){
	// 0 -businka
	// 1 - nit'
	val busy = readLine().toString().map{if (it =='o') 0 else 1}
	val length = busy.size
	val nitN = busy.sum()
	val busyN = length - nitN
	//println("$busyN $nitN")
	if (busyN == 0){
		println("YES")
		return
	}
	val zlp = nitN.rem(busyN)
	if (zlp.rem(2) == 0) println("YES") else println("NO")

}


fun main(args: Array<String>) {
    val chain = readLine()!!.toCharArray()
    checkChain(chain)
}

fun checkChain(chain: CharArray) {
    val char1 = '-'
    val char0 = 'o'

    val char1Count = chain.filter { it == char1 }.count()
    val char0Count = chain.filter { it == char0 }.count()

    if (char0Count == 0 || char1Count == 0) return print("YES")

    if (char0Count > char1Count) {
        return if (char0Count % char1Count == 0) print("YES") else print("NO")
    } else if (char0Count < char1Count) {
        return if (char1Count % char0Count == 0) print("YES") else print("NO")
    } else if (char0Count == char1Count) {
        return print("YES")
    }
}


fun main() {
    val necklace = readLine()!!
    val numPearls = necklace.count { it == 'o' }
    print(if ((necklace.length - numPearls) % numPearls == 0) "YES" else "NO")
}


fun main(args: Array<String>) {
    val (links, pearls) = readLine()!!.partition { it == '-' }
    println(if (links.length % pearls.length == 0) "YES" else "NO")
}


import com.sun.org.apache.xpath.internal.operations.Bool
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.max
import kotlin.math.min
import java.io.IOException
import jdk.nashorn.internal.runtime.ScriptingFunctions.readLine
import java.util.StringTokenizer
import java.io.InputStreamReader
import java.io.BufferedReader
import java.io.InputStream
import kotlin.math.abs

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

fun solve() {
    val scanner = Scanner(System.`in`)
    val str = scanner.next()
    var a = 0
    var b = 0
    for (c in str) {
        if (c == '-')
            b++
        else
            a++
    }
    if (a == 0 || b % a == 0)
        print("YES")
    else
        print("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()
    }
}

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


fun main() {
    val necklace = readLine()!!
    val numPearls = necklace.count { it == 'o' }
    if (numPearls == 0) return print("YES")
    print(if ((necklace.length - numPearls) % numPearls == 0) "YES" else "NO")
}


fun main(args: Array<String>) {
    val chain = readLine()!!.toCharArray()
    checkChain(chain)
}

fun checkChain(chain: CharArray) {
    val char1 = '-'
    val char0 = 'o'

    val char1Count = chain.filter { it == char1 }.count()
    val char0Count = chain.filter { it == char0 }.count()

    if (char0Count == 0 || char1Count == 0) return print("YES")

    if (char0Count > char1Count) {
        return if (char0Count % char1Count == 0) print("YES") else print("NO")
    } else if (char0Count < char1Count) {
        return if (char1Count % char0Count == 0) print("YES") else print("NO")
    }
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.PriorityQueue
import java.util.SortedMap
import java.util.StringTokenizer
import java.util.TreeMap
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val r0 = readInt()
    val g0 = readInt()

    var D = HashMap<State, ModInt>()
    D.add(r0, g0, ModInt(1))

    for(h in 1..200000) {
        val Di = HashMap<State, ModInt>()
        for((state, v) in D) {
            var (r, g) = state
            if(r < h) r = 0
            if(g < h) g = 0
            if(r != 0) Di.add(r-h, g, v)
            if(g != 0) Di.add(r, g-h, v)
        }
        if(Di.isEmpty()) break
        D = Di
    }

    val ans = D.values.sum()

    println(ans.int)
}

fun MutableMap<State, ModInt>.add(r: Int, g: Int, v: ModInt) {
    val state = State(r, g)
    this[state] = (this[state] ?: ModInt(0)) + v
}

data class State(val r: Int, val g: Int) {
    val hash = r.bitConcat(g).hash().toInt()
    override fun hashCode(): Int = hash
}

fun splitmix64(seed: Long): Long {
    var x = seed - 7046029254386353131
    x = (x xor (x ushr 30)) * -4658895280553007687
    x = (x xor (x ushr 27)) * -7723592293110705685
    return (x xor (x ushr 31))
}
@JvmField val nonce64 = random.nextLong()
fun Long.hash() = splitmix64(nonce64 xor this)

fun Int.bitConcat(other: Int) = toLong().shl(32) or other.toLong().and(0xffff_ffff)

const val BILLION7 = 1e9.toInt() + 7
const val MODINT_BASE = BILLION7
const val MODINT_TOTIENT = MODINT_BASE - 1 // assumes MODINT_BASE is prime

inline infix fun Int.umod(base: Int) = Math.floorMod(this, base)
inline infix fun Long.umod(base: Long) = Math.floorMod(this, base)
inline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)

fun Int.powMod(exponent: Int, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = umod(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}

inline fun Int.toModInt() = ModInt(this umod MODINT_BASE)
inline fun Long.toModInt() = ModInt(this umod MODINT_BASE)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    operator fun plus(other: ModInt) = // MODINT_BASE < 2^30
        (int + other.int).let { if(it >= MODINT_BASE) ModInt(it - MODINT_BASE) else ModInt(it) }
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = if(int == MODINT_BASE - 1) ModInt(0) else ModInt(int + 1)

    operator fun minus(other: ModInt) =
        (int - other.int).let { if(it < 0) ModInt(it + MODINT_BASE) else ModInt(it) }
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = if(int == 0) ModInt(MODINT_BASE - 1) else ModInt(int - 1)
    operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)

    inline operator fun times(other: ModInt) = times(other.int)
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent umod MODINT_TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MODINT_BASE))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent umod MODINT_TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(MODINT_TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun sum() = indices.sumByModInt(::get)
    fun product() = indices.productByModInt(::get)

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))
inline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =
    ModIntArray(IntArray(capacity) { init(it).int })

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@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() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


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

val MOD = 1_000_000_007

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val R = ni()
    val G = ni()
    var H = 0
    while((H + 1) * (H + 2) / 2 <= R + G) H++
    val N = min(R, G)
    var cur = IntArray(1_000_000)
    var next = IntArray(1_000_000)
    cur[0] = 1
    var sum = 0L
    for (i in H - 1 downTo 0) {
      val size = min(N, H * (H + 1) / 2 - i * (i + 1) / 2)
      val nsize = min(N, H * (H + 1) / 2 - (i + 1) * (i + 2) / 2)
      for (j in 0 .. size) {
        next[j] = 0
        if (j <= nsize) next[j] += cur[j]
        val nj = j - (i + 1)
        if ((0 .. nsize).contains(nj)) {
          next[j] += cur[nj]
        }
        if (next[j] > MOD) next[j] -= MOD
      }
//      debug(next.take(10).toLongArray())
      val tmp = cur
      cur = next
      next = tmp
      sum += size
    }
    debug{"sum:$sum"}
    var ans = 0L
    val remain = R + G - H * (H + 1) / 2
    for (r in 0 .. remain) {
      val j = N - r
      if (cur.indices.contains(j)) ans += cur[j]
    }
    out.println(ans % 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<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()
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.PriorityQueue
import java.util.SortedMap
import java.util.StringTokenizer
import java.util.TreeMap
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val r0 = readInt()
    val g0 = readInt()

    var D = ModIntArray(r0 + 1)
    D[r0] = ModInt(1)

    for(h in 1..200000) {
        val Di = ModIntArray(r0 + 1)
        val s = g0 - h * (h-1) / 2 + r0
        var ok = false
        for(r in D.indices) {
            if(D[r].int == 0) continue
            val g = s - r
            if(r >= h) {
                Di[r-h] += D[r]
                ok = true
            }
            if(g >= h) {
                Di[r] += D[r]
                ok = true
            }
        }
        if(!ok) break
        D = Di
    }

    val ans = D.sum()

    println(ans.int)
}

fun MutableMap<Int, ModInt>.add(state: Int, v: ModInt) {
    this[state] = (this[state] ?: ModInt(0)) + v
}

const val BILLION7 = 1e9.toInt() + 7
const val MODINT_BASE = BILLION7
const val MODINT_TOTIENT = MODINT_BASE - 1 // assumes MODINT_BASE is prime

inline infix fun Int.umod(base: Int) = Math.floorMod(this, base)
inline infix fun Long.umod(base: Long) = Math.floorMod(this, base)
inline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)

fun Int.powMod(exponent: Int, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = umod(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}

inline fun Int.toModInt() = ModInt(this umod MODINT_BASE)
inline fun Long.toModInt() = ModInt(this umod MODINT_BASE)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    operator fun plus(other: ModInt) = // MODINT_BASE < 2^30
        (int + other.int).let { if(it >= MODINT_BASE) ModInt(it - MODINT_BASE) else ModInt(it) }
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = if(int == MODINT_BASE - 1) ModInt(0) else ModInt(int + 1)

    operator fun minus(other: ModInt) =
        (int - other.int).let { if(it < 0) ModInt(it + MODINT_BASE) else ModInt(it) }
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = if(int == 0) ModInt(MODINT_BASE - 1) else ModInt(int - 1)
    operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)

    inline operator fun times(other: ModInt) = times(other.int)
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent umod MODINT_TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MODINT_BASE))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent umod MODINT_TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(MODINT_TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))
inline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =
    ModIntArray(IntArray(capacity) { init(it).int })

fun ModIntArray.sum() = indices.sumByModInt(::get)
fun ModIntArray.product() = indices.productByModInt(::get)

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@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() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.PriorityQueue
import java.util.SortedMap
import java.util.StringTokenizer
import java.util.TreeMap
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val r0 = readInt()
    val g0 = readInt()

    var D = ModIntArray(r0 + 1)
    D[r0] = ModInt(1)

    for(h in 1..200000) {
        val Di = ModIntArray(D.size)
        val s = g0 - h * (h-1) / 2 + r0
        var ok = false
        for(r in D.indices) {
            val v = D[r]
            if(v.int == 0) continue
            val g = s - r
            if(r >= h) {
                Di[r-h] += v
                ok = true
            }
            if(g >= h) {
                Di[r] += v
                ok = true
            }
        }
        if(!ok) break
        D = Di
    }

    val ans = D.sum().int

    println(ans)
}

const val BILLION7 = 1e9.toInt() + 7
const val MODINT_BASE = BILLION7
const val MODINT_TOTIENT = MODINT_BASE - 1 // assumes MODINT_BASE is prime

inline infix fun Int.umod(base: Int) = Math.floorMod(this, base)
inline infix fun Long.umod(base: Long) = Math.floorMod(this, base)
inline infix fun Long.umod(base: Int) = Math.floorMod(this, base.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = (toLong() * other).umod(mod)

fun Int.powMod(exponent: Int, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = umod(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}

inline fun Int.toModInt() = ModInt(this umod MODINT_BASE)
inline fun Long.toModInt() = ModInt(this umod MODINT_BASE)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    operator fun plus(other: ModInt) = // MODINT_BASE < 2^30
        (int + other.int).let { if(it >= MODINT_BASE) ModInt(it - MODINT_BASE) else ModInt(it) }
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = if(int == MODINT_BASE - 1) ModInt(0) else ModInt(int + 1)

    operator fun minus(other: ModInt) =
        (int - other.int).let { if(it < 0) ModInt(it + MODINT_BASE) else ModInt(it) }
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = if(int == 0) ModInt(MODINT_BASE - 1) else ModInt(int - 1)
    operator fun unaryMinus() = if(int == 0) this else ModInt(MODINT_BASE - int)

    inline operator fun times(other: ModInt) = times(other.int)
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MODINT_BASE))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent umod MODINT_TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MODINT_BASE))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent umod MODINT_TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(MODINT_TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray(capacity: Int) = ModIntArray(IntArray(capacity))
inline fun ModIntArray(capacity: Int, init: (Int) -> ModInt) =
    ModIntArray(IntArray(capacity) { init(it).int })

fun ModIntArray.sum() = indices.sumByModInt(::get)
fun ModIntArray.product() = indices.productByModInt(::get)

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@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() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


import java.util.*
import kotlin.math.min

//30/11/2019
fun main(args: Array<String>) = with(Scanner(System.`in`)) {
  val t = nextInt()
  for (i in 0 until t) {
    val n = nextInt()
    val k = nextInt()
    val d = nextInt()
    val series = (0 until n).map { nextInt() }.toIntArray()
    println(solve(series, k, d))
  }
}

fun solve(n: IntArray, k: Int, d: Int): Long {
  val diffSet = DiffSet(1000000)
  for (i in 0 until d) {
    diffSet.inc(n[i])
  }
  var minDiffSize = diffSet.diffSize
  for (j in 1 .. (n.size - d)) {
    diffSet.dec(n[j - 1])
    diffSet.inc(n[d + j - 1])
    minDiffSize = min(minDiffSize, diffSet.diffSize)
  }
  return minDiffSize
}

class DiffSet(val size: Int) {
  private val myValues: IntArray = IntArray(size)
  var diffSize = 0L

  fun inc(v: Int) {
    if (myValues[v]++ == 0) {
      diffSize++
    }
  }

  fun dec(v: Int) {
    if (--myValues[v] == 0) {
      diffSize--
    }
  }
}


import java.io.BufferedReader
import java.io.Closeable
import java.io.InputStreamReader
import java.util.*

fun main() {
    FastReader().use { rdr ->
        val t = rdr.nextInt()
        val output = IntArray(t)
        for (tc in 0 until t) {
            val n = rdr.nextInt()
            val k = rdr.nextInt()
            val d = rdr.nextInt()
            val a = IntArray(n) { rdr.nextInt() }
            var min = Int.MAX_VALUE
            val c = hashMapOf<Int, Int>()
            for (j in 0 until d) {
                c.increment(a[j])
            }
            for (i in 0..(n - d)) {
                if (i != 0) {
                    c.decrement(a[i - 1])
                    c.increment(a[i + (d - 1)])
                }
                if (c.size < min) {
                    min = c.size
                }
            }
            output[tc] = min
        }
        println(output.joinToString("\n"))
    }
}

private fun <T : Any?> MutableMap<T, Int>.increment(key: T) {
    this[key] = this.getOrDefault(key, 0) + 1
}

private fun <T : Any?> MutableMap<T, Int>.decrement(key: T) {
    val v = this.getOrDefault(key, 0)
    if (v == 1)
        remove(key)
    else
        this[key] = v - 1
}

class FastReader() : Closeable {
    private val rdr = BufferedReader(InputStreamReader(System.`in`))
    private var tkn: StringTokenizer? = null

    fun nextLine(): String {
        return rdr.readLine()
    }

    fun nextInt(): Int {
        if (tkn == null || !tkn!!.hasMoreElements())
            tkn = StringTokenizer(nextLine())
        return tkn!!.nextToken().toInt()
    }

    override fun close() {
        rdr.close()
    }
}


import kotlin.math.min

fun main() {
    val tests = readLine()!!.toInt()
    for (test in 0 until tests) {
        val (n, k, d) = readLine()!!.split(" ").map { it.toInt() }
        if (k == 1 || d == 1) {
            readLine()
            println("1")
        } else {
            val a = readLine()!!.split(" ").map { it.toInt() }
            val current = mutableMapOf<Int, Int>()
            for (i in 0 until d) {
                current[a[i]] = (current[a[i]] ?: 0) + 1
            }
            var m = current.keys.size
            var count = m
            for (i in d until n) {
                current[a[i - d]] = (current[a[i - d]] ?: 0) - 1
                if(current[a[i-d]]!! == 0) {
                    count--
                }
                current[a[i]] = (current[a[i]] ?: 0) + 1
                if(current[a[i]]!! == 1) {
                    count++
                }
                m = min(m, count)
            }
            println(m)
        }
    }
}


import kotlin.math.min

fun main() {
    val t = readLine()!!.toInt()
    for (q in 1..t) {
        val (n, k, d) = readLine()!!.split(" ").map { it.toInt() }
        val a = readLine()!!.split(" ").map { it.toInt() }
        var count = d
        for (i in 0..a.size - d) {
            val set = mutableSetOf<Int>()
            for (j in 0 until d) {
                set.add(a[i + j])
            }
            count = min(set.size, count)
        }
        println(count)
    }
}


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

    val numQueries = readInt()
    val sols = IntArray(numQueries)
    for (query in 0 until numQueries) {
        val (totalDays, _, numConsecutiveDays) = readInts()
        val dayToShow = readInts()
        val showToNumDays = mutableMapOf<Int, Int>().withDefault { 0 }
        for (day in 0 until numConsecutiveDays) {
            val show = dayToShow[day]
            showToNumDays[show] = showToNumDays.getValue(show) + 1
        }
        sols[query] = showToNumDays.size
        for (day in 1..totalDays - numConsecutiveDays) {
            val showToRemove = dayToShow[day - 1]
            val showToAdd = dayToShow[day + numConsecutiveDays - 1]
            showToNumDays[showToRemove] = showToNumDays.getValue(showToRemove) - 1
            if (showToNumDays[showToRemove] == 0) showToNumDays.remove(showToRemove)
            showToNumDays[showToAdd] = showToNumDays.getValue(showToAdd) + 1
            if (showToNumDays.size < sols[query]) sols[query] = showToNumDays.size
        }
    }
    print(sols.joinToString(System.lineSeparator()))
}


fun main() {
    val t = readInt()
    repeat(t) {
        val (n, k, d) = readInts()
        val a = readInts()
        val cc = mutableListOf<Int>()
        for (i in 0..a.size - d) {
            val r = a.subList(i, i + d).toSet()
            cc.add(r.size)
        }
        println(cc.min())
    }
}

private fun readInt() = readLine()!!.toInt()

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


fun readIntList() = readLine()!!.split(' ').map(String::toInt).toMutableList()
fun readLongList() = readLine()!!.split(' ').map(String::toLong).toMutableList()
fun readStringList() = readLine()!!.split(' ').toMutableList()
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()

fun main(args: Array<String>) {

    val t = readInt()
    (1..t).forEach {
        val (n, k, d) = readIntList()
        val elems = Array(k, { 0 })
        val a = readIntList()

        var min = 1_000_000

        for(i in 0..n - d){
            var set = hashSetOf<Int>()
            var j = i

            while (j < i + d)
                set.add(a[j++])

            min = kotlin.math.min(min , set.size)
        }

        println(min)
    }

}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING")

import java.io.PrintWriter
import java.util.PriorityQueue
import java.util.SortedMap
import java.util.StringTokenizer
import java.util.TreeMap
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln // immediate println for interactive

fun main() {
    output {
        val T = readInt()

        repeat(T) {
            val n = readInt()
            val k = readInt()
            val d = readInt()
            val A = readIntArray(n)

            val bag = HashBag<Int>()
            for(i in 0 until d) {
                bag.add(A[i])
            }

            var ans = bag.numDistinct
            for(i in d until n) {
                bag.add(A[i])
                bag.remove(A[i-d])
                ans = min(ans, bag.numDistinct)
            }

            println(ans)
        }
    }
}

val Bag<*>.numDistinct get() = countMap.size

interface Bag<T> : Collection<T> {
    val countMap: Map<T, Int>

    fun getCount(element: T): Int = countMap[element] ?: 0
    val elements: Set<T> get() = countMap.keys
    val entries: Set<Map.Entry<T, Int>> get() = countMap.entries

    override fun iterator(): Iterator<T> = sequence {
        for((e, cnt) in countMap) {
            repeat(cnt) { yield(e) }
        }
    }.iterator()

    override fun contains(element: T): Boolean = countMap.containsKey(element)
}

private fun Bag<*>._size() = countMap.values.sum()
private fun Bag<*>._equals(other: Any?) = when {
    this === other -> true
    other is Bag<*> -> countMap == other.countMap
    else -> false
}
private fun Bag<*>._hashCode() = countMap.hashCode()

class BagImpl<T>(override val countMap: Map<T, Int>): Bag<T>, AbstractCollection<T>() {
    override val size = _size()
    override fun equals(other: Any?) = _equals(other)
    override fun hashCode() = _hashCode()
    override fun contains(element: T) = super<Bag>.contains(element)
    override fun iterator() = super.iterator()
}
fun <T> Bag(countMap: Map<T, Int>): Bag<T> = BagImpl(countMap)

interface MutableBag<T> : Bag<T>, MutableCollection<T> {
    val _countMap: MutableMap<T, Int>
    var _size: Int

    override fun add(element: T): Boolean { add(element, 1); return true }
    fun add(element: T, occurrences: Int): Int {
        require(occurrences >= 0)
        val oldCount = getCount(element)
        _countMap[element] = oldCount + occurrences
        _size += occurrences
        return oldCount
    }

    override fun remove(element: T): Boolean = remove(element, 1) > 0
    fun remove(element: T, occurrences: Int): Int {
        require(occurrences >= 0)
        val oldCount = getCount(element)
        val m = minOf(occurrences, oldCount)
        when(oldCount) {
            0 -> return 0
            m -> _countMap.remove(element)
            else -> _countMap[element] = oldCount - m
        }
        _size -= m
        return oldCount
    }

    fun setCount(element: T, occurrences: Int): Int {
        require(occurrences >= 0)
        val oldCount = getCount(element)
        if(occurrences == 0) _countMap.remove(element)
        else _countMap[element] = occurrences
        _size += occurrences - oldCount
        return oldCount
    }

    override fun iterator(): MutableIterator<T> = object: MutableIterator<T> {
        private val mapIterator = _countMap.iterator()
        private var rem = 0
        private lateinit var lastEntry: MutableMap.MutableEntry<T, Int>
        private var removed = true
        override fun hasNext() = rem > 0 || mapIterator.hasNext()
        override fun next(): T {
            if(rem == 0) {
                lastEntry = mapIterator.next()
                rem = lastEntry.value
            }
            rem--
            removed = false
            return lastEntry.key
        }
        override fun remove() {
            if(removed) error("")
            lastEntry.setValue(lastEntry.value - 1)
            if(lastEntry.value == 0) mapIterator.remove()
            _size--
            removed = true
        }
    }
}

abstract class AbstractMutableBag<T>: MutableBag<T>, AbstractMutableCollection<T>() {
    final override val countMap: Map<T, Int> get() = _countMap
    final override val size get() = _size
    override fun equals(other: Any?) = _equals(other)
    override fun hashCode() = _hashCode()
    override fun contains(element: T) = super<MutableBag>.contains(element)
    override fun iterator() = super.iterator()
    override fun add(element: T): Boolean = super.add(element)
    override fun addAll(elements: Collection<T>): Boolean =
        if(elements is Bag<T>) {
            for((e, n) in elements.countMap) add(e, n)
            true
        } else super.addAll(elements)
    override fun remove(element: T): Boolean = super<MutableBag>.remove(element)
    override fun removeAll(elements: Collection<T>): Boolean =
        if(elements is Bag<T>) {
            var modified = false
            for((e, n) in elements.countMap) if(remove(e, n) > 0) modified = true
            modified
        } else super.removeAll(elements)
}

class HashBag<T>(override val _countMap: HashMap<T, Int>): AbstractMutableBag<T>() {
    constructor(): this(HashMap())

    override var _size = _size()
}

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@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 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() }

@JvmField val _writer = PrintWriter(OUTPUT, false)
inline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <R, V> R._shuffle(rnd: Random, get: R.(Int) -> V, set: R.(Int, V) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, IntArray::get, IntArray::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, LongArray::get, LongArray::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, DoubleArray::get, DoubleArray::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, CharArray::get, CharArray::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()


fun main(args : Array<String>) {
    val t = readLine()!!.toInt()

    repeat(t) {
        val (n, k, d) = readLine()!!.split(" ") .map{it.toInt()}
        val aa = readLine()!!.split(" ").map{it.toInt()}

        var minCnt = Math.min(k, d)
        for (i in 0..n-d) {
            val cnt = aa.slice(i until i+d).toSet().size
            if (cnt < minCnt) minCnt = cnt
        }

        println(minCnt)
    }
}


fun main() {
    val map : MutableMap<Int, Int> = mutableMapOf()

    val t = readLine()!!.toInt()
    repeat(t) {
        val (_, _, d) = readLine()!!
            .split(' ')
            .map { it.toInt() }

        val schedule = readLine()!!
            .split(' ')
            .map { it.toInt() }
            .toMutableList()

        map.clear()
        for (index in schedule.indices) {
            val serial = schedule[index]
            val day = index + 1

            map[serial] = day

            var count = 0
            for ((_, value) in map)
                if (day - value < d)
                    count ++

            schedule[index] = if (day >= d)
                count
            else Int.MAX_VALUE
        }
        println(schedule.min())
    }
}


fun main(args: Array<String> ) {
    val t = readLine()!!.toInt()
    (1..t).forEach {
        val (n, k, d) = readLine()!!.split(" ").map { it.toInt() }
        val x = readLine()!!.split(" ").map { it.toInt() - 1 }
        var c = IntArray(k)
        var r = k
        var s = 0
        (0..n-1).forEach {
            if ( c[ x[it] ] == 0 ) s++
            c[ x[it] ] ++
            if ( it >= d ) {
                c[ x[ it-d ] ] --
                if ( c[ x[ it-d ] ] == 0 ) s--
            }
            if ( it >= d-1 ) {
                if ( s < r ) r = s
            }
        }
        println( r )
    }
}


fun main() {

    var count = readLine()!!.toInt()

    for(c in 0 until count) {
        var (n, k, d) = readLine()!!.split(" ").map { it.toInt() }
        var numbers = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

        var set = numbers.take(k).toMutableSet()
        var numNumber = set.size
        for(i in k until n) {
            set.remove(numbers[i - k])
            set.add(numbers[i])
            numNumber = Math.min(numNumber, set.size)
        }

        println(numNumber)
    }
}


import java.io.*
import java.lang.Math.*
import java.math.BigInteger
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.sqrt

typealias IndexPair<Type> = Pair<Type, Int>
typealias IntIndexPair = IndexPair<Int>
typealias IntIntPair = Pair<Int, Int>

typealias IntMatrix = Array<IntArray>
typealias LongMatrix = Array<LongArray>

typealias ListArray<Type> = Array<MutableList<Type>>

typealias Graph = IntMatrix

typealias Edge = Pair<Int, Int>
typealias EdgeArray = Array<Edge>
typealias WeightedGraph = Array<EdgeArray>

typealias TotalEdge = Triple<Int, Int, Int>
typealias TotalEdgeArray = Array<TotalEdge>

fun init() { }

const val MODULO = 1000 * 1000 * 1000 + 7

fun solve() {
    val n = readLong() - 1

    var nearestRoot = sqrt(n * 2.0).toLong()
    while (nearestRoot * (nearestRoot + 1) > 2 * n) --nearestRoot
    val sum = nearestRoot * (nearestRoot + 1) / 2

    val answer = n - sum
    out.println(answer + 1)
}

fun stress() {
    val rnd = Random(1234)

    for (it in 0 until 100) {
        val expected = brute()
        val actual = fast()

        if (expected != actual) {
            System.err.println("Gotcha!")
            System.err.println("$expected $actual")

            break
        }
    }
}

fun fast() {

}

fun brute() {

}

fun Long.mod() : Long {
    var result = this % MODULO
    if (result < 0) result += MODULO
    return result
}

infix fun Long.add(other : Long) = (this + other).mod()
infix fun Long.sub(other : Long) = this add -other.mod()
infix fun Long.mult(other : Long) = (this.mod() * other.mod()).mod()

fun Long.even() = (this and 1L) == 0L
fun Long.odd() = !even()

fun Int.even() = (this and 1) == 0
fun Int.odd() = !even()

infix fun Long.binpow(power : Long) : Long {
    if (power == 0L) return 1L

    val half = binpow(power shl 1)

    var result = half mult half
    if (power.odd()) {
        result = result mult this
    }

    return result
}

val stepsXY = arrayOf(
        arrayOf(0, -1),
        arrayOf(0, 1),
        arrayOf(-1, 0),
        arrayOf(1, 0)
)

class IndexedWeightedGraph(private val n : Int, private val edges: TotalEdgeArray) {

    private val graph : Graph

    private fun buildGraphForEdges(
            edgeFilter : (index : Int, edge : TotalEdge) -> Boolean = { _, _ -> true }
    ) : Graph {
        val builder = GraphBuilder()
        edges
            .forEachIndexed { index, edge ->
                if (edgeFilter(index, edge)) {
                    val (first, second, _ ) = edge

                    builder.addDirectedEdge(first, index)
                    builder.addDirectedEdge(second, index)
                }
            }

        return builder.build(n)
    }

    init {
        graph = buildGraphForEdges()
    }

    var root : Int = -1
    lateinit var inTree : BooleanArray
    lateinit var tree : Graph

    fun kruskalTree(root : Int) : Long {
        this.root = root

        inTree = BooleanArray(edges.size) { false }

        val dsu = DSU(n)

        edges
            .mapIndexed { index, (_, _, w) -> index to w }
            .sortedBy { it.second }
            .forEach {
                val edge = edges[it.first]
                inTree[it.first] = dsu.union(edge.first, edge.second)
            }

        tree = buildGraphForEdges { index, _ -> inTree[index] }

        return edges
                .mapIndexed { index, (_, _, w)  -> if (inTree[index]) w.toLong() else 0L }
                .sum()
    }

    private fun to(from : Int, index : Int) : Int {
        val edge = edges[index]
        return if (from == edge.first) edge.second else edge.first
    }

    fun buildLca() {
        calculateTimes()
        calculateParents()
        calculatePathInfo()
    }

    lateinit var timesIn : IntArray
    lateinit var timesOut : IntArray
    private var time = -1

    private fun calculateTimes() {
        timesIn = IntArray(n) { -1 }
        timesOut = IntArray(n) { -1 }
        this.time = 0

        timeDfs(root)
    }

    private fun timeDfs(from : Int, parent : Int = -1) {
        timesIn[from] = time++

        for (index in tree[from]) {
            val to = to(from, index)
            if (to == parent) continue

            timeDfs(to, from)
        }

        timesOut[from] = time++
    }

    lateinit var parents : Array<IntArray>
    private val maxBit = 19

    private fun calculateParents() {
        parents = Array(maxBit) { IntArray(n) { -1 } }

        parentDfs(root, root)

        for (bit in 0 until maxBit - 1) {
            for (v in 0 until n) {
                val parent = parents[bit][v]
                parents[bit + 1][v] = parents[bit][parent]
            }
        }
    }

    private fun parentDfs(from : Int, parent : Int = -1) {
        parents[0][from] = parent

        for (index in tree[from]) {
            val to = to(from, index)
            if (to == parent) continue

            parentDfs(to, from)
        }
    }

    lateinit var maxEdges : Array<IntArray>

    private fun calculatePathInfo() {
        maxEdges = Array(maxBit) { IntArray(n) { -1 } }

        for (v in 0 until n){
            for (index in tree[v]) {
                val to = to(v, index)
                if (to == parents[0][v]) continue

                maxEdges[0][to] = edges[index].third
            }
        }

        for (bit in 0 until maxBit - 1) {
            for (v in 0 until n) {
                val parent = parents[bit][v]
                maxEdges[bit + 1][v] = max(
                        maxEdges[bit][v],
                        maxEdges[bit][parent]
                )
            }
        }
    }

    fun getOnPath(a : Int, b : Int) : Int {
        var answer = Int.MIN_VALUE

        answer = max(answer, getOnLcaPath(a, b))
        answer = max(answer, getOnLcaPath(b, a))

        return answer
    }

    private fun getOnLcaPath(start : Int, other : Int) : Int {
        var answer = Int.MIN_VALUE

        if (timesIn[start] <= timesIn[other] && timesOut[other] <= timesOut[start]) {
            return answer
        }

        var v = start
        for (bit in maxBit - 1 downTo 0) {
            val parent = parents[bit][v]
            if (timesIn[parent] > timesIn[other] || timesOut[other] > timesOut[parent]) {
                answer = max(answer, maxEdges[bit][v])
                v = parent
            }
        }

        answer = max(answer, maxEdges[0][v])

        return answer
    }
}

fun yesNo(yes : Boolean) {
    out.println(if (yes) "YES" else "NO")
}

fun run() {
    init()
    solve()
    out.close()
}

fun main(args: Array<String>) {
    run()
}

val ONLINE_JUDGE = !File("input.txt").exists()

val input = BufferedReader(
        if (ONLINE_JUDGE) InputStreamReader(System.`in`) else FileReader("input.txt")
)
val out =
        if (ONLINE_JUDGE) PrintWriter(System.out)
        else PrintWriter("output.txt")

fun readStrings(separator: String = " ", emptyWords: Boolean = false) : Array<String> {
    val line = input.readLine()

    val list = ArrayList<String>()
    var builder = StringBuilder()

    for (i in 0..line.length) {
        if (i == line.length || separator.contains(line[i])) {
            if (emptyWords || builder.isNotEmpty()) {
                list.add(builder.toString())
                builder = StringBuilder()
            }
        } else {
            builder.append(line[i])
        }
    }

    return list.toTypedArray()
}

fun readString(separator: String = " ") =
        readStrings(separator).first()

fun readInts(separator: String = " ") =
        readStrings(separator).map(String::toInt).toIntArray()

fun readDecreasedInts(separator : String = " ") =
        readInts(separator).map { it - 1 }.toIntArray()

fun readSortedInts(separator: String = " ") : IntArray {
    val a = readInts(separator)

    val aInteger = Array(a.size) { a[it] }
    Arrays.sort(aInteger)

    return aInteger.toIntArray()
}

fun readInt(separator: String = " ") =
        readInts(separator).first()

fun readLongs(separator: String = " ") =
        readStrings(separator).map(String::toLong).toLongArray()

fun readLong(separator: String = " ") =
        readLongs(separator).first()

fun readDoubles(separator: String = " ") =
        readStrings(separator).map(String::toDouble).toDoubleArray()

fun readDouble(separator: String = " ") =
        readDoubles(separator).first()

fun readBigIntegers(separator: String = " ") =
        readStrings(separator).map { BigInteger(it) }.toTypedArray()

fun readBigInteger(separator: String = " ") =
        readBigIntegers(separator).first()

fun readTree(n : Int, indexing : Int = 1) =
    readGraph(n, n - 1, true, indexing)

fun readGraph(n: Int, m : Int,
              undirected : Boolean = true,
              indexing : Int = 1) : Graph {
    val builder = GraphBuilder()

    for (i in 1..m) {
        var (from, to) = readInts()

        from -= indexing
        to -= indexing

        if (undirected) builder.addEdge(from, to)
        else builder.addDirectedEdge(from, to)
    }

    return builder.build(n)
}

fun readWeightedGraph(n : Int, m : Int,
                      undirected : Boolean = true,
                      indexing : Int = 1) : WeightedGraph {
    val builder = GraphBuilder()

    for (i in 1..m) {
        var (from, to, weight) = readInts()

        from -= indexing
        to -= indexing

        if (undirected) builder.addEdge(from, to, weight)
        else builder.addDirectedEdge(from, to, weight)
    }

    return builder.buildWeighted(n)
}

fun readTotalEdges(m : Int, indexing : Int = 1) =
        TotalEdgeArray(m) {
            var (from, to, w) = readInts()

            from -= indexing
            to -= indexing

            Triple(from, to, w)
        }

class GraphBuilder {

    private val froms = ArrayList<Int>()
    private val tos = ArrayList<Int>()
    private val weights = ArrayList<Int>()

    fun addEdge(from : Int, to : Int, weight : Int = 1) {
        addDirectedEdge(from, to, weight)
        addDirectedEdge(to, from, weight)
    }

    fun addDirectedEdge(from : Int, to : Int, weight : Int = 1) {
        froms.add(from)
        tos.add(to)
        weights.add(weight)
    }

    private fun calculateFromSizes(n : Int) : IntArray {
        val sizes = IntArray(n) { 0 }
        froms.forEach { ++sizes[it] }
        return sizes
    }

    fun build(n : Int) : Graph {
        val sizes = calculateFromSizes(n)

        val graph = Graph(n) { IntArray(sizes[it]) { 0 } }

        for (i in 0 until n) {
            sizes[i] = 0
        }

        for (i in 0 until froms.size) {
            val from = froms[i]
            val to = tos[i]

            graph[from][sizes[from]++] = to
        }

        return graph
    }

    fun buildWeighted(n : Int) : WeightedGraph {
        val sizes = calculateFromSizes(n)

        val graph = WeightedGraph(n) { EdgeArray(sizes[it]) { -1 to 0 } }

        for (i in 0 until n) {
            sizes[i] = 0
        }

        for (i in 0 until froms.size) {
            val from = froms[i]
            val to = tos[i]
            val weight = weights[i]

            graph[from][sizes[from]++] = to to weight
        }

        return graph
    }
}

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

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

fun getDivisors(x : Int) : MutableList<Int> {
    val divisors = ArrayList<Int>()

    var d = 1
    while (d * d <= x) {
        if (x % d == 0) {
            if (d != 1) divisors.add(d)
            if (x != d) divisors.add(x / d)
        }

        ++d
    }

    return divisors
}

fun getPrimeDivisors(xx : Int) : MutableList<Int> {
    val divisors = ArrayList<Int>()

    var d = 2
    var x = xx
    while (d * d <= x) {
        if (x % d == 0) {
            divisors.add(d)
            while (x % d == 0) {
                x /= d
            }
        }

        ++d
    }

    if (x > 1) divisors.add(x)

    return divisors
}

fun checkIndex(index : Int, size : Int) =
        0 <= index && index < size

fun checkCell(x : Int, n : Int, y : Int, m : Int) =
        checkIndex(x, n) && checkIndex(y, m)

fun toChar(index : Int, start : Char) =
        (index + start.toInt()).toChar()

class DSU {

    var sizes : IntArray
    var ranks : IntArray
    var parents : IntArray

    constructor(n : Int)
    : this(
            IntArray(n) { 1 }
    )

    constructor(sizes : IntArray) {
        val size = sizes.size
        this.sizes = sizes
        this.ranks = IntArray(size) { 1 }
        this.parents = IntArray(size) { it }
    }

    operator fun get(v : Int) : Int {
        val parent = parents[v]
        if (parent == v) return v
        parents[v] = get(parent)
        return parents[v]
    }

    fun union(aUniting : Int, bUniting : Int) : Boolean {
        var a = get(aUniting)
        var b = get(bUniting)

        if (a == b) return false

        if (ranks[a] < ranks[b]) {
            val tmp = a
            a = b
            b = tmp
        }

        parents[b] = a
        sizes[a] += sizes[b]
        if (ranks[a] == ranks[b]) ++ranks[a]

        return true
    }

    fun size(v : Int) : Int = sizes[get(v)]
}

class FenwickTree(n : Int) {

    val size = n + 1
    val tree = LongArray(size) { 0L }

    fun update(index : Int, delta : Int) {
        var x = index + 1
        while (x < size) {
            tree[x] = tree[x] + delta
            x += x and -x
        }
    }

    operator fun get(start : Int, end : Int) =
            get(end) - get(start - 1)

    operator fun get(index : Int) : Long {
        var result : Long = 0

        var x = index + 1
        while (x > 0) {
            result += tree[x]
            x -= x and -x
        }

        return result
    }
}


fun main() {
    val n = readLong() - 1

    val bs = (1..2e7.toLong()).binarySearchBy {
        regime(it).compareTo(n)
    }

    val l = bs.value - if(bs.exactFound) 0 else 1
    val ans = n - regime(l) + 1

    println(ans)
}

fun regime(l: Long) = l * (l-1) / 2

fun LongRange.binarySearchBy(goldilocks: (Long) -> Int): BinarySearchResult<Long> {
    var low = start
    var high = endInclusive

    while (low <= high) {
        val mid = low / 2 + high / 2 + (low % 2 + high % 2) / 2
        val cmp = goldilocks(mid)

        if (cmp < 0)
            low = mid + 1
        else if (cmp > 0)
            high = mid - 1
        else
            return BinarySearchResult(mid, true) // key found
    }
    return BinarySearchResult(low, false)  // key not found
}
data class BinarySearchResult<out T>(val value: T, val exactFound: Boolean)

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readDouble() = readLn().toDouble()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readStringSeq() = readLn().splitToSequence(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readIntSeq() = readStringSeq().map { it.toInt() }
fun readIntArray(size: Int) = readIntSeq().iterator().let { i -> IntArray(size) { i.next() } }
fun readDoubles() = readStrings().map { it.toDouble() }
fun readDoubleSeq() = readStringSeq().map { it.toDouble() }
fun readDoubleArray(size: Int) = readDoubleSeq().iterator().let { i -> DoubleArray(size) { i.next() } }
fun readLongs() = readStrings().map { it.toLong() }
fun readLongSeq() = readStringSeq().map { it.toLong() }
fun readLongArray(size: Int) = readLongSeq().iterator().let { i -> LongArray(size) { i.next() } }

class Output {
    private val sb = StringBuilder()
    fun print(o: Any?) { sb.append(o) }
    fun println() { sb.append('\n') }
    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 main() {
    solve()
}

private fun solve() {
    val n = readLong()

    if (n == 1L) {
        println(1)
        return
    }
    var counter = 1L

    var i = 1L
    var ans = 0L
    while (i <= n) {
//        println(i)
        if (i + counter >= n) {
            ans = 1 + (n - i)
//            break
        }

        i += counter
        counter++
    }
    println(ans)
}

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


import kotlin.math.sqrt

fun main() {
    fun readLong() = readLine()!!.toLong()

    val n = readLong() - 1
    val x = ((sqrt((1 + 8 * n).toDouble()) - 1) / 2).toLong()
    print(1 + n - (x * (x + 1) / 2))
}


fun main() {
    solve()
}

private fun solve() {
    val n = readLong()

    if (n == 1L) {
        println(1)
        return
    }
    var counter = 1

    var i = 1
    var ans = 0L
    while (i <= n) {
        if (i + counter >= n) {
            ans = 1 + (n - i)
            break
        }

        i += counter
        counter++
    }
    println(ans)
}

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


import kotlin.math.sqrt

fun main() {
    fun readLong() = readLine()!!.toLong()

    val n = readLong() - 1
    val x = ((sqrt((1 + 8 * n).toFloat()) - 1) / 2).toInt()
    print(1 + n - (x * (x + 1) / 2))
}


import java.io.*
import java.lang.Math.*
import java.math.BigInteger
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.sqrt

typealias IndexPair<Type> = Pair<Type, Int>
typealias IntIndexPair = IndexPair<Int>
typealias IntIntPair = Pair<Int, Int>

typealias IntMatrix = Array<IntArray>
typealias LongMatrix = Array<LongArray>

typealias ListArray<Type> = Array<MutableList<Type>>

typealias Graph = IntMatrix

typealias Edge = Pair<Int, Int>
typealias EdgeArray = Array<Edge>
typealias WeightedGraph = Array<EdgeArray>

typealias TotalEdge = Triple<Int, Int, Int>
typealias TotalEdgeArray = Array<TotalEdge>

fun init() { }

const val MODULO = 1000 * 1000 * 1000 + 7

fun solve() {
    val n = readLong() - 1

    val nearestRoot = sqrt(n * 2.0).toLong()
    val sum = nearestRoot * (nearestRoot + 1) / 2

    val answer = n - sum
    out.println(answer + 1)
}

fun stress() {
    val rnd = Random(1234)

    for (it in 0 until 100) {
        val expected = brute()
        val actual = fast()

        if (expected != actual) {
            System.err.println("Gotcha!")
            System.err.println("$expected $actual")

            break
        }
    }
}

fun fast() {

}

fun brute() {

}

fun Long.mod() : Long {
    var result = this % MODULO
    if (result < 0) result += MODULO
    return result
}

infix fun Long.add(other : Long) = (this + other).mod()
infix fun Long.sub(other : Long) = this add -other.mod()
infix fun Long.mult(other : Long) = (this.mod() * other.mod()).mod()

fun Long.even() = (this and 1L) == 0L
fun Long.odd() = !even()

fun Int.even() = (this and 1) == 0
fun Int.odd() = !even()

infix fun Long.binpow(power : Long) : Long {
    if (power == 0L) return 1L

    val half = binpow(power shl 1)

    var result = half mult half
    if (power.odd()) {
        result = result mult this
    }

    return result
}

val stepsXY = arrayOf(
        arrayOf(0, -1),
        arrayOf(0, 1),
        arrayOf(-1, 0),
        arrayOf(1, 0)
)

class IndexedWeightedGraph(private val n : Int, private val edges: TotalEdgeArray) {

    private val graph : Graph

    private fun buildGraphForEdges(
            edgeFilter : (index : Int, edge : TotalEdge) -> Boolean = { _, _ -> true }
    ) : Graph {
        val builder = GraphBuilder()
        edges
            .forEachIndexed { index, edge ->
                if (edgeFilter(index, edge)) {
                    val (first, second, _ ) = edge

                    builder.addDirectedEdge(first, index)
                    builder.addDirectedEdge(second, index)
                }
            }

        return builder.build(n)
    }

    init {
        graph = buildGraphForEdges()
    }

    var root : Int = -1
    lateinit var inTree : BooleanArray
    lateinit var tree : Graph

    fun kruskalTree(root : Int) : Long {
        this.root = root

        inTree = BooleanArray(edges.size) { false }

        val dsu = DSU(n)

        edges
            .mapIndexed { index, (_, _, w) -> index to w }
            .sortedBy { it.second }
            .forEach {
                val edge = edges[it.first]
                inTree[it.first] = dsu.union(edge.first, edge.second)
            }

        tree = buildGraphForEdges { index, _ -> inTree[index] }

        return edges
                .mapIndexed { index, (_, _, w)  -> if (inTree[index]) w.toLong() else 0L }
                .sum()
    }

    private fun to(from : Int, index : Int) : Int {
        val edge = edges[index]
        return if (from == edge.first) edge.second else edge.first
    }

    fun buildLca() {
        calculateTimes()
        calculateParents()
        calculatePathInfo()
    }

    lateinit var timesIn : IntArray
    lateinit var timesOut : IntArray
    private var time = -1

    private fun calculateTimes() {
        timesIn = IntArray(n) { -1 }
        timesOut = IntArray(n) { -1 }
        this.time = 0

        timeDfs(root)
    }

    private fun timeDfs(from : Int, parent : Int = -1) {
        timesIn[from] = time++

        for (index in tree[from]) {
            val to = to(from, index)
            if (to == parent) continue

            timeDfs(to, from)
        }

        timesOut[from] = time++
    }

    lateinit var parents : Array<IntArray>
    private val maxBit = 19

    private fun calculateParents() {
        parents = Array(maxBit) { IntArray(n) { -1 } }

        parentDfs(root, root)

        for (bit in 0 until maxBit - 1) {
            for (v in 0 until n) {
                val parent = parents[bit][v]
                parents[bit + 1][v] = parents[bit][parent]
            }
        }
    }

    private fun parentDfs(from : Int, parent : Int = -1) {
        parents[0][from] = parent

        for (index in tree[from]) {
            val to = to(from, index)
            if (to == parent) continue

            parentDfs(to, from)
        }
    }

    lateinit var maxEdges : Array<IntArray>

    private fun calculatePathInfo() {
        maxEdges = Array(maxBit) { IntArray(n) { -1 } }

        for (v in 0 until n){
            for (index in tree[v]) {
                val to = to(v, index)
                if (to == parents[0][v]) continue

                maxEdges[0][to] = edges[index].third
            }
        }

        for (bit in 0 until maxBit - 1) {
            for (v in 0 until n) {
                val parent = parents[bit][v]
                maxEdges[bit + 1][v] = max(
                        maxEdges[bit][v],
                        maxEdges[bit][parent]
                )
            }
        }
    }

    fun getOnPath(a : Int, b : Int) : Int {
        var answer = Int.MIN_VALUE

        answer = max(answer, getOnLcaPath(a, b))
        answer = max(answer, getOnLcaPath(b, a))

        return answer
    }

    private fun getOnLcaPath(start : Int, other : Int) : Int {
        var answer = Int.MIN_VALUE

        if (timesIn[start] <= timesIn[other] && timesOut[other] <= timesOut[start]) {
            return answer
        }

        var v = start
        for (bit in maxBit - 1 downTo 0) {
            val parent = parents[bit][v]
            if (timesIn[parent] > timesIn[other] || timesOut[other] > timesOut[parent]) {
                answer = max(answer, maxEdges[bit][v])
                v = parent
            }
        }

        answer = max(answer, maxEdges[0][v])

        return answer
    }
}

fun yesNo(yes : Boolean) {
    out.println(if (yes) "YES" else "NO")
}

fun run() {
    init()
    solve()
    out.close()
}

fun main(args: Array<String>) {
    run()
}

val ONLINE_JUDGE = !File("input.txt").exists()

val input = BufferedReader(
        if (ONLINE_JUDGE) InputStreamReader(System.`in`) else FileReader("input.txt")
)
val out =
        if (ONLINE_JUDGE) PrintWriter(System.out)
        else PrintWriter("output.txt")

fun readStrings(separator: String = " ", emptyWords: Boolean = false) : Array<String> {
    val line = input.readLine()

    val list = ArrayList<String>()
    var builder = StringBuilder()

    for (i in 0..line.length) {
        if (i == line.length || separator.contains(line[i])) {
            if (emptyWords || builder.isNotEmpty()) {
                list.add(builder.toString())
                builder = StringBuilder()
            }
        } else {
            builder.append(line[i])
        }
    }

    return list.toTypedArray()
}

fun readString(separator: String = " ") =
        readStrings(separator).first()

fun readInts(separator: String = " ") =
        readStrings(separator).map(String::toInt).toIntArray()

fun readDecreasedInts(separator : String = " ") =
        readInts(separator).map { it - 1 }.toIntArray()

fun readSortedInts(separator: String = " ") : IntArray {
    val a = readInts(separator)

    val aInteger = Array(a.size) { a[it] }
    Arrays.sort(aInteger)

    return aInteger.toIntArray()
}

fun readInt(separator: String = " ") =
        readInts(separator).first()

fun readLongs(separator: String = " ") =
        readStrings(separator).map(String::toLong).toLongArray()

fun readLong(separator: String = " ") =
        readLongs(separator).first()

fun readDoubles(separator: String = " ") =
        readStrings(separator).map(String::toDouble).toDoubleArray()

fun readDouble(separator: String = " ") =
        readDoubles(separator).first()

fun readBigIntegers(separator: String = " ") =
        readStrings(separator).map { BigInteger(it) }.toTypedArray()

fun readBigInteger(separator: String = " ") =
        readBigIntegers(separator).first()

fun readTree(n : Int, indexing : Int = 1) =
    readGraph(n, n - 1, true, indexing)

fun readGraph(n: Int, m : Int,
              undirected : Boolean = true,
              indexing : Int = 1) : Graph {
    val builder = GraphBuilder()

    for (i in 1..m) {
        var (from, to) = readInts()

        from -= indexing
        to -= indexing

        if (undirected) builder.addEdge(from, to)
        else builder.addDirectedEdge(from, to)
    }

    return builder.build(n)
}

fun readWeightedGraph(n : Int, m : Int,
                      undirected : Boolean = true,
                      indexing : Int = 1) : WeightedGraph {
    val builder = GraphBuilder()

    for (i in 1..m) {
        var (from, to, weight) = readInts()

        from -= indexing
        to -= indexing

        if (undirected) builder.addEdge(from, to, weight)
        else builder.addDirectedEdge(from, to, weight)
    }

    return builder.buildWeighted(n)
}

fun readTotalEdges(m : Int, indexing : Int = 1) =
        TotalEdgeArray(m) {
            var (from, to, w) = readInts()

            from -= indexing
            to -= indexing

            Triple(from, to, w)
        }

class GraphBuilder {

    private val froms = ArrayList<Int>()
    private val tos = ArrayList<Int>()
    private val weights = ArrayList<Int>()

    fun addEdge(from : Int, to : Int, weight : Int = 1) {
        addDirectedEdge(from, to, weight)
        addDirectedEdge(to, from, weight)
    }

    fun addDirectedEdge(from : Int, to : Int, weight : Int = 1) {
        froms.add(from)
        tos.add(to)
        weights.add(weight)
    }

    private fun calculateFromSizes(n : Int) : IntArray {
        val sizes = IntArray(n) { 0 }
        froms.forEach { ++sizes[it] }
        return sizes
    }

    fun build(n : Int) : Graph {
        val sizes = calculateFromSizes(n)

        val graph = Graph(n) { IntArray(sizes[it]) { 0 } }

        for (i in 0 until n) {
            sizes[i] = 0
        }

        for (i in 0 until froms.size) {
            val from = froms[i]
            val to = tos[i]

            graph[from][sizes[from]++] = to
        }

        return graph
    }

    fun buildWeighted(n : Int) : WeightedGraph {
        val sizes = calculateFromSizes(n)

        val graph = WeightedGraph(n) { EdgeArray(sizes[it]) { -1 to 0 } }

        for (i in 0 until n) {
            sizes[i] = 0
        }

        for (i in 0 until froms.size) {
            val from = froms[i]
            val to = tos[i]
            val weight = weights[i]

            graph[from][sizes[from]++] = to to weight
        }

        return graph
    }
}

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

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

fun getDivisors(x : Int) : MutableList<Int> {
    val divisors = ArrayList<Int>()

    var d = 1
    while (d * d <= x) {
        if (x % d == 0) {
            if (d != 1) divisors.add(d)
            if (x != d) divisors.add(x / d)
        }

        ++d
    }

    return divisors
}

fun getPrimeDivisors(xx : Int) : MutableList<Int> {
    val divisors = ArrayList<Int>()

    var d = 2
    var x = xx
    while (d * d <= x) {
        if (x % d == 0) {
            divisors.add(d)
            while (x % d == 0) {
                x /= d
            }
        }

        ++d
    }

    if (x > 1) divisors.add(x)

    return divisors
}

fun checkIndex(index : Int, size : Int) =
        0 <= index && index < size

fun checkCell(x : Int, n : Int, y : Int, m : Int) =
        checkIndex(x, n) && checkIndex(y, m)

fun toChar(index : Int, start : Char) =
        (index + start.toInt()).toChar()

class DSU {

    var sizes : IntArray
    var ranks : IntArray
    var parents : IntArray

    constructor(n : Int)
    : this(
            IntArray(n) { 1 }
    )

    constructor(sizes : IntArray) {
        val size = sizes.size
        this.sizes = sizes
        this.ranks = IntArray(size) { 1 }
        this.parents = IntArray(size) { it }
    }

    operator fun get(v : Int) : Int {
        val parent = parents[v]
        if (parent == v) return v
        parents[v] = get(parent)
        return parents[v]
    }

    fun union(aUniting : Int, bUniting : Int) : Boolean {
        var a = get(aUniting)
        var b = get(bUniting)

        if (a == b) return false

        if (ranks[a] < ranks[b]) {
            val tmp = a
            a = b
            b = tmp
        }

        parents[b] = a
        sizes[a] += sizes[b]
        if (ranks[a] == ranks[b]) ++ranks[a]

        return true
    }

    fun size(v : Int) : Int = sizes[get(v)]
}

class FenwickTree(n : Int) {

    val size = n + 1
    val tree = LongArray(size) { 0L }

    fun update(index : Int, delta : Int) {
        var x = index + 1
        while (x < size) {
            tree[x] = tree[x] + delta
            x += x and -x
        }
    }

    operator fun get(start : Int, end : Int) =
            get(end) - get(start - 1)

    operator fun get(index : Int) : Long {
        var result : Long = 0

        var x = index + 1
        while (x > 0) {
            result += tree[x]
            x -= x and -x
        }

        return result
    }
}


fun main() {
    solve()
}

private fun solve() {
    val n = readLong()

    if (n == 1L) {
        println(1)
        return
    }
    var counter = 1

    var i = 1
    var ans = 0L
    while (i <= n) {
        if (i + counter >= n) {
            ans = 1 + (n - i)
        }

        i += counter
        counter++
    }
    println(ans)
}

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


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

const val IMPOSSIBLE = -100000000000000000L

fun main() {
    val k = readLine()!!.toInt()
    val fs = readLine()!!.split(" ").map { it.toLong() }
    readLine()
    val n = readLine()!!.toInt()
    var dpPrev = LongArray(n + 1) { IMPOSSIBLE }
    dpPrev[0] = 0L
    val segTrees = Array(3) { SegmentTree(0, n / 10) }
    for (e in 5 downTo 0) {
        for (t in 0..2) {
            segTrees[t].value.fill(IMPOSSIBLE)
        }
        for (j in 0..n / 10) {
            segTrees[j % 3][j] = dpPrev[j] - (((10 * j) / 3).toLong() * fs[e])
        }
        val dp = LongArray(n + 1) { IMPOSSIBLE }
        for (j in 0..n) {
            for (t in 0..2) {
                val correction = if ((j % 3) >= t) 0L else -1L
                dp[j] = max(dp[j], segTrees[t][(j - (9 * (k - 1)) + 9) / 10, j / 10] + (fs[e] * ((j / 3).toLong() + correction)))
                for (j2 in j - (9 * k) until j - (9 * (k - 1))) {
                    if (j2 >= 0 && j2 % 10 == 0) {
                        if ((j - j2) % 3 == 0) {
                            dp[j] = max(dp[j], segTrees[t][j2 / 10] + (fs[e] * ((j / 3).toLong() + correction)))
                        } else {
                            val cancel = ((j - (9 * (k - 1)) - j2) / 3).toLong()
                            dp[j] = max(dp[j], segTrees[t][j2 / 10] + (fs[e] * ((j / 3).toLong() + correction - cancel)))
                        }
                    }
                }
            }
            if (dp[j] < 0L) {
                dp[j] = IMPOSSIBLE
            }
        }
        dpPrev = dp
    }
    println(dpPrev[n])
}

class SegmentTree(val treeFrom: Int, val treeTo: Int) {
    val value: LongArray
    val length: Int

    init {
        var e = 0
        while (1 shl e < treeTo - treeFrom + 1) {
            e++
        }
        value = LongArray(1 shl (e + 1))
        length = 1 shl e
    }

    operator fun set(index: Int, delta: Long) {
        var node = index - treeFrom + length
        value[node] = delta
        node = node shr 1
        while (node > 0) {
            value[node] = max(value[node shl 1], value[(node shl 1) + 1])
            node = node shr 1
        }
    }

    operator fun get(index: Int) = value[index - treeFrom + length]

    operator fun get(fromIndex: Int, toIndex: Int): Long {
        if (toIndex < fromIndex) {
            return IMPOSSIBLE
        }

        var from = max(treeFrom, fromIndex) + length - treeFrom
        var to = min(treeTo, toIndex) + length - treeFrom + 1
        var res = IMPOSSIBLE
        while (from + (from and -from) <= to) {
            res = max(res, value[from / (from and -from)])
            from += from and -from
        }
        while (to - (to and -to) >= from) {
            res = max(res, value[(to - (to and -to)) / (to and -to)])
            to -= to and -to
        }
        return res
    }
}


import java.util.*
fun main(){
    val s=Scanner(System.`in`)
    var r=s.next()
    var n=r.length
    var x:Int = -1
    var answer:String=""
    for( i in 0..n-1){
        if(r[i]=='p'){
            answer += r[i]
            x=i
            break
        }
        else
            answer += r[i]
    }
    x++
    answer += "://"
    for (i in x..n-1){
       if(r[i]=='r' && r[i+1]=='u' && i!=x){
           answer+='.'
           answer+="ru"
           x=i+1
           break
       }
        else
           answer+=r[i]
    }

    if(x!=n-1){
        x++
        answer+='/'
        for(i in x..n-1){
            answer+=r[i]
        }
    }
    print(answer)
}


import java.util.*
fun main(){
    val s=Scanner(System.`in`)
    var r=s.next()
    var n=r.length
    var x:Int = -1
    var answer:String=""
    for( i in 0..n-1){
        if(r[i]=='p'){
            answer += r[i]
            x=i
            break
        }
        else
            answer += r[i]
    }
    x++
    answer += "://"
    for (i in x..n-1){
       if(r[i]=='r' && r[i+1]=='u'){
           answer+='.'
           answer+="ru"
           x=i+1
           break
       }
        else
           answer+=r[i]
    }

    if(x!=n-1){
        x++
        answer+='/'
        for(i in x..n-1){
            answer+=r[i]
        }
    }
    print(answer)
}


import javax.print.attribute.IntegerSyntax
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readDouble() = readLn().toDouble()
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() }

fun isDiverse(s: String): Boolean {
    val sortedSet = s.toSortedSet()
    return sortedSet.size == s.length &&
            sortedSet.last().toInt() - sortedSet.first().toInt() + 1 == sortedSet.size
}

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

    val all = mutableSetOf<String>()

    for (i in 0 until s.length + 1) {
        for(ch in 'a'..'z') {
            val other = s.substring(0, i) + ch + s.substring(i)
            all.add(other)
        }
    }

    println(all.size)
}


fun main() {
    val l = readLine()!!.length
    print(26 * (l + 1) - l)
}


import java.util.*

fun main() {
    var n = readLine()!!

    println((n.length+1)*25+1)
}


import java.io.BufferedInputStream

fun main() {
    val pows = LongArray(40)
    pows[0] = 1L
    for (e in 1..39) {
        pows[e] = 7L * pows[e - 1]
    }
    val jin = FastScanner()
    val n = jin.nextInt().toLong()
    val m = jin.nextInt().toLong()
    var e = 1
    var pow = 7L
    while (pow < n) {
        e++
        pow *= 7L
    }
    var f = 1
    pow = 7L
    while (pow < m) {
        f++
        pow *= 7L
    }
    val used = mutableSetOf<Int>()
    var answer = 0
    var hour = 0L
    var minute = 0L
    fun recur(d: Int) {
        if (d == e + f) {
            if (hour < n && minute < m) {
                answer++
            }
        } else {
            for (digit in 0..6) {
                if (digit !in used) {
                    used.add(digit)
                    if (d < e) {
                        hour += digit.toLong() * pows[d]
                    } else {
                        minute += digit.toLong() * pows[d - e]
                    }
                    recur(d + 1)
                    if (d < e) {
                        hour -= digit.toLong() * pows[d]
                    } else {
                        minute -= digit.toLong() * pows[d - e]
                    }
                    used.remove(digit)
                }
            }
        }
    }
    recur(0)
    println(answer)
}

class FastScanner {
    private val BS = 1 shl 16
    private val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC
    private var `in`: BufferedInputStream? = null

    constructor() {
        `in` = BufferedInputStream(System.`in`, BS)
    }

    private val char: Char
        private get() {
            while (bId == size) {
                size = try {
                    `in`!!.read(buf)
                } catch (e: Exception) {
                    return NC
                }
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c >= '0' && c <= '9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
}


import java.io.BufferedReader
import java.io.BufferedWriter

class PerfectPower(val number: Long, val power: Long)
class ProblemE {
    private fun BufferedReader.readInt(): Int = this.readLine().toInt()
    private fun BufferedReader.readIntArray(delimiter: String = " ") =
        this.readLine().split(delimiter).map { it.toInt() }.toIntArray()

    private fun BufferedWriter.writeLine(s: String) {
        this.write(s)
        this.newLine()
    }

    private fun IntArray.swap(i: Int, j: Int) {
        val tmp = this[i]
        this[i] = this[j]
        this[j] = tmp
    }

    private fun solveTest(input: BufferedReader, output: BufferedWriter) {
        val perfectPowers = mutableMapOf<Long, MutableList<PerfectPower>>()
        for (i in 2..(1e6).toLong()) {
            var k = i
            for (p in 2..22L) {
                k *= i
                if (k > 1e6) break
                val s = perfectPowers.getOrDefault(k, mutableListOf())
                s.add(PerfectPower(i, p))
                perfectPowers[k] = s
            }
        }

        val (n, m) = input.readLine().split(" ").map { it.toLong() }
        var numDistinct = 1L
        for(i in 2..n) {
            if(perfectPowers.contains(i)) {
                var maxCommon = 0L
                for(r in perfectPowers[i]!!) {
                    maxCommon = maxOf(m / r.power, maxCommon)
                }
                numDistinct += m - maxCommon
            } else {
                numDistinct += m
            }
        }
        output.writeLine(numDistinct.toString())
    }

    fun solve(input: BufferedReader, output: BufferedWriter) {
        solveTest(input, output)
        input.close()
        output.close()
    }

}

fun main() {
    val solution = ProblemE()
    solution.solve(System.`in`.bufferedReader(), System.out.bufferedWriter())
}