output_description: Print the maximum possible value of the greatest common divisor of a sequence
  a_1, a_2, ..., a_N that satisfies the condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
attempt: # 求める出力は，mの約数iのうち n*i <= m を満たす最大の整数n．
  
  N, M = map(int, input().split())
  fracs = []
  i = 2
  m = M
  # mの素因数分解を求める
  while m > 1 and M**0.5:
      while m % i == 0:
          m //= i
          if len(fracs) == 0:
              fracs.append([i, 1])
          elif fracs[-1][0] == i:
              fracs[-1][1] += 1
          else:
              fracs.append([i, 1])
      i += 1
  
  if m != 1:
      fracs.append(m, 1)
  
  # 約数を全て列挙する
  divisors = []
  
  
  def search(i, p):
      for j in range(fracs[i][1] + 1):
          if i != len(fracs) - 1:
              new_p = p * fracs[i][0] ** j
              search(i + 1, new_p)
          else:
              divisors.append(p * fracs[i][0] ** j)
  
  
  search(0, 1)
  
  print(sorted(list(filter(lambda x: x * N <= M, divisors)))[-1])
  
problem_description: Statement
  
  You are given integers N and M.
  
  Consider a sequence a of length N consisting of positive integers such that
  a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest
  common divisor of a_1, a_2, ..., a_N.
samples: [{"input": "3 14", "output": "2\n    \n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common\ndivisor is 2, and this is the maximum value.\n\n* * *"}, {"input": "10 123", "output": "3\n    \n\n* * *"}, {"input": "100000 1000000000", "output": "10000"}]