import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int W = sc.nextInt(); int D = sc.nextInt(); while(D!=1){ int w1d = W/D/D; W = W - w1d; D--; } System.out.println(W); } }