import java.util.Scanner; class no3017{ public static void main(String[] args) { Scanner stdIn=new Scanner(System.in); int s=stdIn.nextInt(),k=stdIn.nextInt(); System.out.print(s%k); } }