import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    res = n - k
    print(res if k != 1 else 0)


if __name__ == '__main__':
    resolve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    n, k = map(int, input().split())
    res = n - k
    print(res if k != 1 else 0) resolve n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k res = n - k res n - k n k print(res if k != 1 else 0) print res if k != 1 else 0 k != 1 k 1 res 0 if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve input = sys.stdin.readline sys.stdin.readline input f_inf = float('inf') float('inf') f_inf mod = 10 ** 9 + 7 10 ** 9 + 7 mod def resolve():
    n, k = map(int, input().split())
    res = n - k
    print(res if k != 1 else 0) def resolve():
    n, k = map(int, input().split())
    res = n - k
    print(res if k != 1 else 0) resolve
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    res = n - k
    print(res if k != 1 else 0)


if __name__ == '__main__':
    resolve()
