#import pysnooper
import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
from itertools import accumulate,combinations#,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,k=map(int,input().split())
print(n%k if n>=k else 0) import os,re,sys,operator,math,heapq,string os re sys operator math heapq string from itertools import accumulate,combinations from sys import stdin,setrecursionlimit setrecursionlimit(10**6) setrecursionlimit 10**6 10 6 input=stdin.readline input stdin.readline stdin readline n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k print(n%k if n>=k else 0) print n%k if n>=k else 0 n>=k n k n%k n k 0 n,k=map(int,input().split()) map(int,input().split()) n input=stdin.readline stdin.readline input k=map(int,input().split()) map(int,input().split()) k
#import pysnooper
import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
from itertools import accumulate,combinations#,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,k=map(int,input().split())
print(n%k if n>=k else 0)