import java.math.*;
import java.util.*;

public class Main 
{ public static void main(String[] args) 
  { Scanner sc = new Scanner(System.in);
    BigInteger n = new BigInteger(sc.next());
    BigInteger k = new BigInteger(sc.next()); 
    System.out.println(n.remainder(k));
  }
}
