import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    if K==1:
        print(0)
    else:
        print(N-K)

if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 INF = float('inf') INF float('inf') float 'inf' MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def main():
    N, K = map(int, readline().split())
    if K==1:
        print(0)
    else:
        print(N-K) main N, K = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline 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__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def main():
    N, K = map(int, readline().split())
    if K==1:
        print(0)
    else:
        print(N-K) def main():
    N, K = map(int, readline().split())
    if K==1:
        print(0)
    else:
        print(N-K) main read = sys.stdin.read sys.stdin.read read INF = float('inf') float('inf') INF
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    if K==1:
        print(0)
    else:
        print(N-K)

if __name__ == '__main__':
    main()
