k,u=input();i=P=1;l={0};exec'l|={P%i*i};P*=i*i;i+=1;'*(u+k);print{i-k for i in l}&l
3,1500
set([0, 2])
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!