# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())
n, k = readmi()
if k == 1:
    print(0)
else:
    a = n - k
    print(a) import sys sys import heapq heapq import re re import bisect bisect import random random import math math import itertools itertools from collections import defaultdict, deque from copy import deepcopy from decimal import * readl= lambda: list(map(int, sys.stdin.readline().split())) readl lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split readt= lambda: tuple(map(int, sys.stdin.readline().split())) readt lambda: tuple(map(int, sys.stdin.readline().split())) tuple(map(int, sys.stdin.readline().split())) tuple map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split read = lambda: sys.stdin.readline().rstrip() read 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 readi = lambda: int(read()) readi lambda: int(read()) int(read()) int read() read readmi = lambda: map(int, sys.stdin.readline().split()) readmi lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split readms = lambda: map(str, sys.stdin.readline().split()) readms lambda: map(str, sys.stdin.readline().split()) map(str, sys.stdin.readline().split()) map str sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split n, k = readmi() n readmi() readmi k if k == 1:
    print(0)
else:
    a = n - k
    print(a) k == 1 k 1 print(0) print 0 a = n - k a n - k n k print(a) print a readms = lambda: map(str, sys.stdin.readline().split()) lambda: map(str, sys.stdin.readline().split()) readms k = readmi() readmi() k readt= lambda: tuple(map(int, sys.stdin.readline().split())) lambda: tuple(map(int, sys.stdin.readline().split())) readt read = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() read n, k = readmi() readmi() n readi = lambda: int(read()) lambda: int(read()) readi readl= lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) readl a = n - k n - k a readmi = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) readmi
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())
n, k = readmi()
if k == 1:
    print(0)
else:
    a = n - k
    print(a)