import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in)); try { long W =Long.parseLong(stdReader.readLine()); long D = Long.parseLong(stdReader.readLine()); while(D>1){ long temp = W /(D*D); W -= temp; D--; } System.out.println(W); } catch (IOException e) { e.printStackTrace(); } } }