Under construction

Still being built. Things may change

K-th Number

Interview

Time limit2sMemory limit128 MB

Summary
Find the k-th smallest value in the N x N multiplication table using binary search with a counting function.
Level

Medium5 of 10

Topics
Binary search, Math
Solved
No attempts yet

Problem

Sejun made an N x N array A. For every pair of integers i and j from 1 to N, A[i][j] = i x j. Put every value of A into a one-dimensional array B, sort B in nondecreasing order, and find the value at 1-based index k, B[k].

The indices of arrays A and B start at 1.

Input

The first line contains the size N of the array. N is a natural number between 1 and 100,000 inclusive.

The second line contains k. k is a natural number between 1 and min(1,000,000,000, N^2) inclusive.

Output

Print B[k], the k-th number in the sorted array B.

Examples1

  1. Example 1

    Input
    3
    7
    
    Expected output
    6