Chloe, a competitive programmer, is tasked with generating a sequence of integers using a specific algorithm. Initially, the sequence contains a single element, which is 1. In each of the following (n - 1) steps, the sequence is modified as follows:
The current sequence is appended to itself.
In the middle of the new sequence, the smallest positive integer that has not been used yet is inserted.
For example:
After the first step, the sequence becomes: [1, 2, 1]
After the second step, it transforms into: [1, 2, 1, 3, 1, 2, 1]
Your task is to find the value of the element at a specific index k in the sequence after performing (n - 1) steps. Note that the indexing is 1-based.
Input Format
The input consists of a single line containing two integers:
n (1 ≤ n ≤ 50): the number of steps to perform.
k (1 ≤ k ≤ 2^n - 1): the index of the element to retrieve from the final sequence.
Output Format
Output a single integer that is the value at the k-th position in the obtained sequence.
Examples
Example 1
Input:
text
3 2
Output:
text
2
Explanation: The obtained sequence is [1, 2, 1, 3, 1, 2, 1]. The number at the second position is 2.
Example 2
Input:
text
4 8
Output:
text
4
Explanation: The obtained sequence is [1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1]. The number at the eighth position is 4.
Task Implementation
Please implement the function to solve the problem and place the solution in the /app/ directory.
Important: place your implementation at /app/solution.py so the verifier can run it.