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(); int ans = 0; while (w > 0) { ans = w; w -= w / d / d; d--; } System.out.println(ans); } }