import java.util.Scanner

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    var N = sc.nextInt()
    val K = sc.nextInt()

    val max = N - K + 1
    val min = if(K > 1){
        1
    }else{
        N
    }
    println(max - min);
}