import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
BigInteger a,b;
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
a = cin.nextBigInteger();
b = cin.nextBigInteger();
BigInteger result=a.mod(b);
System.out.println(result);
}
}
}