fun main() { val sheepNumber = readLine()?.toLong() var second = 1 sheepNumber?.let { var restSheepNumber = it while (restSheepNumber > 0) { restSheepNumber -= second second++ } if (restSheepNumber.toInt() == 0) { println("YES") println(second - 1) } else { println("NO") } } }