import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Yuki051 { public static void main(String[] args) { Yuki051 hoge = new Yuki051(); } Yuki051() { Scanner scanner = new Scanner(System.in); int W = scanner.nextInt(); int D = scanner.nextInt(); for (int i = D; i > 1; i--) { W -= W / D / D; } System.out.println(W); } }