PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000071. Phân hoạch để tối đa ƯCLN (Partition)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phân hoạch để tối đa ƯCLN (Partition)

Partition

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given positive integers NN and MM. Consider all sequences of exactly NN positive integers a1,a2,…,aNa_1,a_2,\ldots,a_N whose sum is MM. For each sequence, take the greatest common divisor (GCD) of all its entries. Find the maximum possible GCD over all such sequences. Print only the maximum value; you need not construct the sequence.

Input

A line containing two integers NN and MM.

Output

Print one integer, the maximum possible GCD.

Subtasks

  • Subtask 1 (20 points): 1≤N≤201\le N\le20, N≤M≤103N\le M\le10^3.

  • Subtask 2 (30 points): 1≤N≤1031\le N\le10^3, N≤M≤106N\le M\le10^6.

  • Subtask 3 (50 points): 1≤N≤1051\le N\le10^5, N≤M≤109N\le M\le10^9.

Examples

Input

3 14

Output

2

Explanation

The sequence (2,4,8)(2,4,8) has three positive entries, sums to 1414, and has GCD 22. Any common divisor dd must divide 1414 and satisfy 3d≤143d\le14. Among the divisors 1,2,7,141,2,7,14, the largest feasible one is 22.