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() 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) slove import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n, k = list(map(int, input().rstrip('\n').split())) n list(map(int, input().rstrip('\n').split())) list map(int, input().rstrip('\n').split()) map int input().rstrip('\n').split() ().rstrip('\n').split ().rstrip('\n') ().rstrip () input rstrip '\n' 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 if __name__ == '__main__':
    slove() __name__ == '__main__' __name__ '__main__' slove() slove 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) 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) slove
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()
