import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    if K == 1:
        print(0)
    else:
        print(N-K)

main() import sys sys int(c) for c in s.split(' ') for c in s.split(' ') c s.split(' ') s.split s split ' ' for c in s.split(' ') int(c) int c s2nn = lambda s: [int(c) for c in s.split(' ')] s2nn lambda s: [int(c) for c in s.split(' ')] [int(c) for c in s.split(' ')] s int(s) for s in ss for s in ss s ss for s in ss int(s) int s ss2nn = lambda ss: [int(s) for s in ss] ss2nn lambda ss: [int(s) for s in ss] [int(s) for s in ss] ss s2nn(s) for s in ss for s in ss s ss for s in ss s2nn(s) s2nn s ss2nnn = lambda ss: [s2nn(s) for s in ss] ss2nnn lambda ss: [s2nn(s) for s in ss] [s2nn(s) for s in ss] ss i2s = lambda: sys.stdin.readline().rstrip() i2s lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip i2n = lambda: int(i2s()) i2n lambda: int(i2s()) int(i2s()) int i2s() i2s i2nn = lambda: s2nn(i2s()) i2nn lambda: s2nn(i2s()) s2nn(i2s()) s2nn i2s() i2s sys.stdin.readline().rstrip() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2ss lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] [sys.stdin.readline().rstrip() for _ in range(n)] n list(sys.stdin.readline().rstrip()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(sys.stdin.readline().rstrip()) list sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)] ii2sss lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)] [list(sys.stdin.readline().rstrip()) for _ in range(n)] n ii2nn = lambda n: ss2nn(ii2ss(n)) ii2nn lambda n: ss2nn(ii2ss(n)) ss2nn(ii2ss(n)) ss2nn ii2ss(n) ii2ss n n ii2nnn = lambda n: ss2nnn(ii2ss(n)) ii2nnn lambda n: ss2nnn(ii2ss(n)) ss2nnn(ii2ss(n)) ss2nnn ii2ss(n) ii2ss n n def main():
    N, K = i2nn()
    if K == 1:
        print(0)
    else:
        print(N-K) main N, K = i2nn() N i2nn() i2nn 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 main() main ii2nn = lambda n: ss2nn(ii2ss(n)) lambda n: ss2nn(ii2ss(n)) ii2nn ss2nn = lambda ss: [int(s) for s in ss] lambda ss: [int(s) for s in ss] ss2nn i2n = lambda: int(i2s()) lambda: int(i2s()) i2n s2nn = lambda s: [int(c) for c in s.split(' ')] lambda s: [int(c) for c in s.split(' ')] s2nn ss2nnn = lambda ss: [s2nn(s) for s in ss] lambda ss: [s2nn(s) for s in ss] ss2nnn i2nn = lambda: s2nn(i2s()) lambda: s2nn(i2s()) i2nn ii2nnn = lambda n: ss2nnn(ii2ss(n)) lambda n: ss2nnn(ii2ss(n)) ii2nnn ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)] lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)] ii2sss def main():
    N, K = i2nn()
    if K == 1:
        print(0)
    else:
        print(N-K) def main():
    N, K = i2nn()
    if K == 1:
        print(0)
    else:
        print(N-K) main i2s = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() i2s ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2ss
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    if K == 1:
        print(0)
    else:
        print(N-K)

main()
