import java.util.Scanner; public class No51 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int w=sc.nextInt(); for(long d=sc.nextInt();d>1&&w>1;d--){ w-=w/(d*d);} System.out.println(w); } }