import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val n = scanner.nextInt()
		val k = scanner.nextInt()
		println(if (k>1) n-k else 0)
	}
}