def slove():

    import sys

    input = sys.stdin.readline

    n, k = list(map(int, input().rstrip('\n').split()))

    if k == 1:

        print((0))

    else:

        print((n - k))





if __name__ == '__main__':

    slove()

import sys





def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7

    n, k = list(map(int, readline().split()))

    if k == 1:

        print((0))

    elif n < k:

        print((1))

    else:

        print((n - k))





if __name__ == '__main__':

    solve()

def slove():
    import sys

    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip("\n").split()))
    if k == 1:
        print((0))
    else:
        print((n - k))


if __name__ == "__main__":
    slove()

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    n, k = list(map(int, readline().split()))
    if k == 1:
        print((0))
    elif n < k:
        print((1))
    else:
        print((n - k))


if __name__ == "__main__":
    solve()

-def slove(): -    import sys +import sys -    input = sys.stdin.readline -    n, k = list(map(int, input().rstrip("\n").split())) + +def solve(): +    readline = sys.stdin.buffer.readline +    mod = 10**9 + 7 +    n, k = list(map(int, readline().split())) +    elif n < k: +        print((1)) -    slove() +    solve()