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() import sys 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) solve readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 n, k = list(map(int, readline().split())) n list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split k if k == 1:
        print(0)
    elif n < k:
        print(1)
    else:
        print(n - k) k == 1 k 1 print(0) print 0 elif n < k:
        print(1)
     n < k n k print(1) print 1 print(n - k) print n - k n k if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve 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) 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) solve
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()
