import logging
import unittest

debug = logging.getLogger(__name__).debug


def input_ints():
    return list(map(int, input().strip().split()))


def _main():
    n, k = input_ints()
    if k == 1:
        print(0)
    else:
        print(n - k)


class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main)


if __name__ == '__main__':
    _main() import logging logging import unittest unittest debug = logging.getLogger(__name__).debug debug logging.getLogger(__name__).debug logging.getLogger(__name__) logging.getLogger logging getLogger __name__ debug def input_ints():
    return list(map(int, input().strip().split())) input_ints return list(map(int, input().strip().split())) list(map(int, input().strip().split())) list map(int, input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split def _main():
    n, k = input_ints()
    if k == 1:
        print(0)
    else:
        print(n - k) _main n, k = input_ints() n input_ints() input_ints 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 class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main) Test def setUp(self):
        import run
        self._test = run

     setUp import run run self._test = run self._test self _test run self self def test_main(self):
        self._test.test_files(self, _main) test_main self._test.test_files(self, _main) self._test.test_files self._test self _test test_files self _main self self unittest.TestCase unittest TestCase if __name__ == '__main__':
    _main() __name__ == '__main__' __name__ '__main__' _main() _main def input_ints():
    return list(map(int, input().strip().split())) def input_ints():
    return list(map(int, input().strip().split())) input_ints debug = logging.getLogger(__name__).debug logging.getLogger(__name__).debug debug def _main():
    n, k = input_ints()
    if k == 1:
        print(0)
    else:
        print(n - k) def _main():
    n, k = input_ints()
    if k == 1:
        print(0)
    else:
        print(n - k) _main class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main) class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main) Test
import logging
import unittest

debug = logging.getLogger(__name__).debug


def input_ints():
    return list(map(int, input().strip().split()))


def _main():
    n, k = input_ints()
    if k == 1:
        print(0)
    else:
        print(n - k)


class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main)


if __name__ == '__main__':
    _main()
