program Project1; {$APPTYPE CONSOLE} var f:text; a, b, c, d:int64; begin assign(f, 'problem.in'); reset(f); read(f, a, b); close(f); c:=0; d:=0; repeat inc(c); if ((c*(c+1)) div 2) mod b=0 then inc(d); until(c=a); assign(f, 'problem.out'); rewrite(f); writeln(f, d); close(f); end.