st = input().split(" ")
n = int(st[0])
m = int(st[1])

if(m == 1):
    print(0)
    exit()

print(n - m) st = input().split(" ") st input().split(" ") ().split () input split " " n = int(st[0]) n int(st[0]) int st[0] st 0 m = int(st[1]) m int(st[1]) int st[1] st 1 if(m == 1):
    print(0)
    exit() m == 1 m 1 print(0) print 0 exit() exit print(n - m) print n - m n m st = input().split(" ") input().split(" ") st m = int(st[1]) int(st[1]) m n = int(st[0]) int(st[0]) n
st = input().split(" ")
n = int(st[0])
m = int(st[1])

if(m == 1):
    print(0)
    exit()

print(n - m)
