import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    if K==1:
        print(0)
    else:
        print(N-K)

main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI def main():
    mod=10**9+7
    N,K=MI()
    if K==1:
        print(0)
    else:
        print(N-K) main mod=10**9+7 mod 10**9+7 10**9 10 9 7 N,K=MI() N MI() MI 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 def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI input = sys.stdin.readline sys.stdin.readline input def I(): return int(input()) def I(): return int(input()) I def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def main():
    mod=10**9+7
    N,K=MI()
    if K==1:
        print(0)
    else:
        print(N-K) def main():
    mod=10**9+7
    N,K=MI()
    if K==1:
        print(0)
    else:
        print(N-K) main
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    if K==1:
        print(0)
    else:
        print(N-K)

main()
