import java.util.Scanner; class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); int W = in.nextInt(); int D = in.nextInt(); int temp = 0; for(int i=1; i<=D-1; i++) { temp = (int)Math.floor(W / D * D); W -= temp; D--; } System.out.println(temp); } }