import Foundation
 
let input_line = readLine()!
 
let split = input_line.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
let N = Int(split[0])!
let K = Int(split[1])!
 
if K == 1 {
    print(0)
} else  {
    print(N - K)
}