program Project1; {$APPTYPE CONSOLE} var f, g : text; i, j , m, n, kist, u : integer; begin assign(f, 'problem.in'); reset(f); read(f, n, m); i := 1; while i <= n do begin u := i; j := 0; while u >= 1 do begin j := j + u; dec(u); end; if (j mod m) = 0 then inc(kist); inc(i); end; assign(g, 'problem.out'); rewrite (g); writeln(g, kist); close(g); end.