# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    if k==1:
        print(0)
    else:
        n-=k
        print(n)
    
resolve() import sys sys sys.setrecursionlimit(10 ** 5 + 10) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 + 10 10 ** 5 10 5 10 def input(): return sys.stdin.readline().strip() input def resolve():
    n,k=map(int,input().split())
    if k==1:
        print(0)
    else:
        n-=k
        print(n)
     resolve n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k if k==1:
        print(0)
    else:
        n-=k
        print(n)
     k==1 k 1 print(0) print 0 n-=k n k print(n) print n resolve() resolve def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def resolve():
    n,k=map(int,input().split())
    if k==1:
        print(0)
    else:
        n-=k
        print(n)
     def resolve():
    n,k=map(int,input().split())
    if k==1:
        print(0)
    else:
        n-=k
        print(n)
     resolve
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    if k==1:
        print(0)
    else:
        n-=k
        print(n)
    
resolve()