program Project2; {$APPTYPE CONSOLE} uses SysUtils; var n,m,a,res,x,i:longint; begin assign(input,'problem.in'); reset(input); read(n,m); close(input); a:=1; if 1 mod m=0 then inc(res); for i:=2 to n do begin inc(a,i) ; if a mod m=0 then inc(res); {x:=i; if (x mod 2<>0) then begin dec(x); inc(a[i],x+1) end; a[i]:=(x+1)*(x div 2); if a mod m=0 then inc(res); a:=0;} end; assign(output,'problem.out'); rewrite(output); writeln(res); close(output); end.