P29004 [洛谷] 【XR-3】Gossip Spreading
普及+
题目描述

Problem Description

Little X wants to explore how fast gossip spreads, so he conducts a social experiment.

There are \( n \) people, where the \( i \)-th person's clothing has a number \( i+1 \). Little X discovers a pattern: when a person with the number \( i \) on their clothing learns a piece of information on a certain day, they will inform the person with the number \( j \) on their clothing the next day, where \( \gcd(i, j) = 1 \) (i.e., the greatest common divisor of \( i \) and \( j \) is 1). On day 0, Little X tells a piece of gossip to the \( k \)-th person, and he wants to know on which day everyone will know this piece of gossip.

It can be proven that there will definitely be a day when everyone knows this piece of gossip.

Hint: You might need to use the Bertrand-Chebyshev Theorem.

Input Format

A single line containing two positive integers \( n \) and \( k \).

Data Range:

  • \( 2 \le n \le 10^{14} \).
  • \( 1 \le k \le n \).

Output Format

A single line containing a positive integer, representing the answer.

Sample Input and Output

Sample Input #1

3 1

Sample Output #1

2

Sample Input #2

6 4

Sample Output #2

1

Notes

Sample 1 Explanation:

The numbers on the clothing of the 3 people are 2 3 4.

On day 0, Little X tells a piece of gossip to the 1st person, whose clothing number is 2.

On day 1, the 1st person will tell the 2nd person because \( \gcd(2, 3) = 1 \), but he will not tell the 3rd person because \( \gcd(2, 4) = 2 \neq 1 \).

On day 2, the 2nd person will tell the 3rd person because \( \gcd(3, 4) = 1 \), and at this point, everyone knows the gossip, so the answer is 2.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1
样例输出
2