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