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