import java.util.*; public class Main_yukicoder3017_1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long s = sc.nextInt(); long k = sc.nextInt(); System.out.println(s % k); sc.close(); } }