def main():
    N, K = [int(x) for x in input().split()]

    if K == 1:
        print(0)
    else:
        print(N - K)

main()
 def main():
    N, K = [int(x) for x in input().split()]

    if K == 1:
        print(0)
    else:
        print(N - K) main int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x N, K = [int(x) for x in input().split()] N [int(x) for x in input().split()] K if K == 1:
        print(0)
    else:
        print(N - K) K == 1 K 1 print(0) print 0 print(N - K) print N - K N K main() main def main():
    N, K = [int(x) for x in input().split()]

    if K == 1:
        print(0)
    else:
        print(N - K) def main():
    N, K = [int(x) for x in input().split()]

    if K == 1:
        print(0)
    else:
        print(N - K) main
def main():
    N, K = [int(x) for x in input().split()]

    if K == 1:
        print(0)
    else:
        print(N - K)

main()

