QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#13464. function

Statistics

Define $P(x)$ as the number of integers $y$ such that $1 < y < x$ and $y^3 \equiv 1 \pmod x$.

Find how many positive integers $x \le n$ satisfy $P(x) = m$.

Input

A single line containing two integers $n$ and $m$.

Output

Output a single integer representing the answer.

Examples

Input 1

10 0

Output 1

8

Input 2

100000000 242

Output 2

24038

Subtasks

For $100\%$ of the data, $1 < n \le 2 \times 10^{10}$ and $0 \le m < n$.

Test Case ID $n$ $m$
$1$ $\le 2\times 10^{10}$ $=666$
$2$ $\le 10^3$
$3$
$4$
$5$
$6$
$7$
$8$ $\le 10^8$ $\ge 300$
$9$
$10$
$11$ $\le 5\times 10^9$ $\ge 200$
$12$
$13$ $=0$
$14$ $\le 2\times 10^{10}$
$15$ $\le 10^8$
$16$
$17$
$18$
$19$
$20$ $\le 2\times 10^{10}$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.