import java.util.Scanner; public class Main{ public static void main(String args[])throws Exception{ Scanner sc=new Scanner(System.in); long money=Long.parseLong(sc.nextLine()); int people=Integer.parseInt(sc.nextLine()); int baka=(int)(money/people); int aho=(int)(baka%1000); System.out.println(baka-aho); } }