import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N, K = Integer.parseInt(sc.next())

    if (K == 1) {
      println(0)
    } else {
      println(N - K)
    }
  }
}