

def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g




n,k = map(int,input().split())

if k==1:
    print(0)
else:
    print(n-k)






 def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b) gcd_core if b == 0:
        return a
    else:
        return gcd_core(b, a % b) b == 0 b 0 return a a return gcd_core(b, a % b) gcd_core(b, a % b) gcd_core b a % b a b a a b b def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g gcd g = gcd_core(arr[0], arr[1]) g gcd_core(arr[0], arr[1]) gcd_core arr[0] arr 0 arr[1] arr 1 for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
     i range(2, len(arr)) range 2 len(arr) len arr g = gcd_core(g, arr[i]) g gcd_core(g, arr[i]) gcd_core g arr[i] arr i return g g arr arr 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:
    print(n-k) k==1 k 1 print(0) print 0 print(n-k) print n-k n k def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b) def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b) gcd_core def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g gcd n,k = map(int,input().split()) map(int,input().split()) n k = map(int,input().split()) map(int,input().split()) k


def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g




n,k = map(int,input().split())

if k==1:
    print(0)
else:
    print(n-k)







