import java.util.Scanner; public class Main { public static void main(String[] a) { Scanner s=new Scanner(System.in); float W=s.nextFloat(),D=s.nextFloat(); while(D>1)W-=(int)(W/D/(D--)); System.out.println((int)W); } }