def input_from_console():
    n, k = map(int, input().split())
    return n, k


def solve(n, k):
    if k == 1:
        return 0
    return n - k


def main():
    n, k = input_from_console()
    print(solve(n, k))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main() def input_from_console():
    n, k = map(int, input().split())
    return n, k input_from_console n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k return n, k return n, k n k def solve(n, k):
    if k == 1:
        return 0
    return n - k solve if k == 1:
        return 0
     k == 1 k 1 return 0 0 return n - k n - k n k n n k k def main():
    n, k = input_from_console()
    print(solve(n, k)) main n, k = input_from_console() n input_from_console() input_from_console k print(solve(n, k)) print solve(n, k) solve n k if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main() __name__ == "__main__" __name__ "__main__" import sys sys if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main() sys.gettrace() sys.gettrace sys gettrace check_cases() check_cases main() main def main():
    n, k = input_from_console()
    print(solve(n, k)) def main():
    n, k = input_from_console()
    print(solve(n, k)) main def input_from_console():
    n, k = map(int, input().split())
    return n, k def input_from_console():
    n, k = map(int, input().split())
    return n, k input_from_console def solve(n, k):
    if k == 1:
        return 0
    return n - k def solve(n, k):
    if k == 1:
        return 0
    return n - k solve
def input_from_console():
    n, k = map(int, input().split())
    return n, k


def solve(n, k):
    if k == 1:
        return 0
    return n - k


def main():
    n, k = input_from_console()
    print(solve(n, k))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()
