Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.

Let's consider the following algorithm of generating a sequence of integers. Initially we have a sequence consisting of a single element equal to 1. Then we perform (n - 1) steps. On each step we take the sequence we've got on the previous step, append it to the end of itself and insert in the middle the minimum positive integer we haven't used before. For example, we get the sequence [1, 2, 1] after the first step, the sequence [1, 2, 1, 3, 1, 2, 1] after the second step.

The task is to find the value of the element with index k (the elements are numbered from 1) in the obtained sequence, i. e. after (n - 1) steps.

Please help Chloe to solve the problem!


-----Input-----

The only line contains two integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 2^{n} - 1).


-----Output-----

Print single integer — the integer at the k-th position in the obtained sequence.


-----Examples-----
Input
3 2

Output
2
Input
4 8

Output
4


-----Note-----

In the first sample the obtained sequence is [1, 2, 1, 3, 1, 2, 1]. The number on the second position is 2.

In the second sample the obtained sequence is [1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1]. The number on the eighth position is 4.

Difficulty: EASY
Tags: Bit manipulation

Sorting

Implementation

Constructive algorithms
Skill types: Bit manipulation

Sorting

Starter code:

Solutions:
(n, k) = [int(x) for x in input().split()]
tmp = n + 1
lan = 2 ** (n + 1) - 1
while lan > 1:
	if k <= lan // 2:
		lan = lan // 2
		tmp = tmp - 1
	elif k >= lan // 2 + 2:
		k = lan // 2 - lan + k
		lan = lan // 2
		tmp = tmp - 1
	if k == lan // 2 + 1:
		break
print(tmp)


(n, k) = map(int, input().split())
while n > -1:
	if 2 ** (n - 1) == k:
		print(n)
		break
	elif 2 ** (n - 1) > k:
		n -= 1
	else:
		k -= 2 ** (n - 1)


(n, k) = input().split(' ')

def func(n, k):
	if k == 2 ** (n - 1):
		return n
	if k > 2 ** (n - 1):
		return func(n - 1, k - 2 ** (n - 1))
	if k < 2 ** (n - 1):
		return func(n - 1, k)
print(func(int(n), int(k)))


(n, k) = map(int, input().split())
ans = 1
while k % 2 == 0:
	ans += 1
	k /= 2
print(ans)


def binarySearch(s, n, ind):
	v = 0
	x = (s >> 1) + 1
	if x < ind:
		ind -= x
		s -= x
		n -= 1
		v = binarySearch(s, n, ind)
	elif x > ind:
		s -= x
		n -= 1
		v = binarySearch(s, n, ind)
	else:
		v = n
	return v
inp = input().split()
n = int(inp[0])
ind = int(inp[1])
s = 0
for i in range(n):
	s = 2 * s + 1
x = binarySearch(s, n, ind)
print(x)


lengthes = dict()
lengthes[0] = 1
for k in range(1, 51):
	lengthes[k] = lengthes[k - 1] * 2 + 1
(n, k) = list(map(int, input().split()))

def rec(n, k):
	if n == 0:
		return 1
	if k <= lengthes[n - 1]:
		return rec(n - 1, k)
	if k == lengthes[n - 1] + 1:
		return n + 1
	return rec(n - 1, k - 1 - lengthes[n - 1])
print(rec(n - 1, k))


from bisect import bisect_left, bisect_right
from itertools import accumulate
R = lambda : map(int, input().split())
(n, k) = R()
while 2 ** n // 2 != k:
	if 2 ** n // 2 < k:
		k = 2 ** n - k
	n -= 1
print(n)


(n, k) = map(int, input().split())
for i in reversed(range(n + 1)):
	if k % pow(2, i) == 0:
		print(i + 1)
		break


(q, w) = map(int, input().split())
i = 1
while w % 2 != 1:
	i += 1
	w //= 2
print(i)


(n, k) = map(int, input().split())
s = 1
p = 1
while p < n:
	s = s * 2 + 1
	p += 1
pos = (s + 1) // 2
while k != pos:
	if k > pos:
		k = k - pos
	s = (s - 1) // 2
	pos = (s + 1) // 2
	n -= 1
print(n)


def find(l, r, need, a_s):
	m = (r + l) // 2
	if need < m:
		return find(l, m - 1, need, a_s - 1)
	elif need > m:
		return find(m + 1, r, need, a_s - 1)
	else:
		return a_s
(n, k) = map(int, input().split())
sz = 1
for i in range(n):
	sz = sz * 2 + 1
print(find(1, sz, k, n) + 1)


def f(n, k):
	m = our[n]
	if m // 2 + 1 == k:
		return n
	return f(n - 1, k % (m // 2 + 1))
our = [0, 1]
(n, k) = map(int, input().split())
while len(our) <= n + 1:
	our.append(our[-1] * 2 + 1)
print(f(n, k))


def p(n, k):
	if k == 2 ** (n - 1):
		return n
	if k > 2 ** (n - 1):
		k -= 2 ** (n - 1)
	return p(n - 1, k)
(n, k) = map(int, input().split())
print(p(n, k))


(n, k) = [int(i) for i in input().split()]

def midreturn(n, k):
	k = k - 1
	l = 2 ** n - 1
	i = 0
	while i <= l:
		mid = (i + l) // 2
		if mid == k:
			print(n)
			break
		elif mid < k:
			i = mid + 1
			n = n - 1
		else:
			l = mid - 1
			n = n - 1
midreturn(n, k)


def recur(n, k):
	if k == 2 ** (n - 1) - 1:
		return n
	elif k > 2 ** (n - 1) - 1:
		return recur(n - 1, k - 2 ** (n - 1))
	else:
		return recur(n - 1, k)
(n, k) = map(int, input().split())
print(recur(n, k - 1))


(n, k) = map(int, input().split())
if k % 2 != 0:
	print(1)
else:
	c = 0
	while k % 2 == 0:
		k = k // 2
		c += 1
	print(c + 1)


def binarySearch(n, k):
	l = 2 ** n - 1
	if k % 2:
		return 1
	low = 1
	high = l
	dn = 0
	while low < high:
		mid = (low + high) / 2
		if mid == k:
			return n - dn
		elif mid < k:
			low = mid + 1
			dn += 1
		else:
			high = mid - 1
			dn += 1
s = input()
number = s.split()
n = int(number[0])
k = int(number[1])
print(binarySearch(n, k))


def sequenceLengthAtStep(step):
	if step == 1:
		return 1
	return sequenceLengthAtStep(step - 1) * 2 + 1

def elementAtPos(pos, steps):
	sequenceLength = sequenceLengthAtStep(steps)
	integer = 1
	firstIntegerPos = 1
	while firstIntegerPos < sequenceLength:
		integerModulus = firstIntegerPos * 2
		if (pos - firstIntegerPos) % integerModulus == 0:
			return integer
		integer += 1
		firstIntegerPos *= 2
	return integer
(steps, pos) = (int(x) for x in input().split())
print(elementAtPos(pos, steps))


def findpoweroftwo(n):
	for i in range(1, 51):
		if 2 ** i == n:
			return i
(n, k) = map(int, input().split())
if k % 2 == 1:
	exit(print(1))
for i in range(n - 1, 0, -1):
	if k & k - 1 == 0:
		exit(print(findpoweroftwo(k) + 1))
	k = abs(2 ** i - k)


def go(n, k):
	if n == 1:
		print(1)
		return
	elif k < 2 ** (n - 1):
		go(n - 1, k)
	elif k == 2 ** (n - 1):
		print(n)
	else:
		go(n - 1, k - 2 ** (n - 1))
(nn, kk) = map(int, input().split())
go(nn, kk)


def proga(s, n, k):
	if n == 0 or (s - 1) // 2 + 1 == k:
		return n + 1
	s //= 2
	if k > s:
		k -= s + 1
	return proga(s, n - 1, k)
(n, k) = map(int, input().split())
n -= 1
s = 1
for i in range(n):
	s *= 2
	s += 1
print(proga(s, n, k))


def sequence(k):
	count = 0
	while k % 2 == 0:
		k //= 2
		count += 1
	return count + 1
(n, K) = [int(i) for i in input().split()]
print(sequence(K))


(n, k) = map(int, input().split())
i = 1
while True:
	if 2 ** (i - 1) == k % 2 ** i:
		print(i)
		break
	i += 1


from math import log
(n, i) = map(float, input().split())
c = 0
while i > 0:
	c = int(log(i, 2))
	if i == i % 2 ** c:
		c -= 1
	i %= 2 ** c
print(int(c + 1))


(n, k) = map(int, input().split())
ans = 1
while True:
	if k % 2 != 0:
		print(ans)
		break
	else:
		k = k // 2
		ans += 1


(n, k) = map(int, input().split())
l = pow(2, n + 1) - 1
while 1:
	if k == l // 2 + 1:
		print(n + 1)
		exit()
	elif k > l // 2 + 1:
		k -= l // 2 + 1
		n -= 1
		l = l // 2
	else:
		l = l // 2
		n -= 1


(n, k) = map(int, input().split())
if k % 4 == 1 or k % 4 == 3:
	print(1)
elif k % 4 == 2:
	print(2)
else:
	m = 8
	a = 3
	while k % m != m // 2:
		m = m * 2
		a += 1
	print(a)


(n, k) = [int(s) for s in input().split()]
lengths = [1]
(n, k) = (n - 1, k - 1)
for i in range(n):
	lengths.append(lengths[-1] * 2 + 1)

def search(n, k):
	if k == 0:
		return 1
	l = lengths[n]
	if k == l // 2:
		return n + 1
	if k < l // 2:
		return search(n - 1, k)
	else:
		return search(n - 1, k - l // 2 - 1)
print(search(n, k))


(n, k) = [int(item) for item in input().split()]
for i in range(1, n + 1):
	if int((k - 2 ** (i - 1)) / 2 ** i) == (k - 2 ** (i - 1)) / 2 ** i:
		print(i)
		break


str = input().split()
n = int(str[0])
k = int(str[1])
left = 1
val = 1
while left * 2 <= k:
	left *= 2
	val += 1
ans = 0
right = 2 * left
mid = left
while mid != k:
	mid = (left + right) // 2
	if mid > k:
		right = mid
	elif mid < k:
		left = mid
	val -= 1
print(val)


(n, k) = map(int, input().split(' '))
a = [1] * 51
for i in range(1, 51):
	a[i] = 2 * a[i - 1]
for i in range(1, 51):
	if (k - a[i] / 2) % a[i] == 0:
		print(i)
		break


a = []
a.append(0)
for i in range(1, 56):
	a.append(1 << i - 1)
(n, k) = map(int, input().split())
for i in range(54, -1, -1):
	if k % a[i] == 0:
		print(i)
		break


(n, k) = list(map(int, input().split()))
while n:
	mid = 2 ** n // 2
	if k == mid:
		print(n)
		break
	if k > mid:
		k -= mid
	n -= 1


from math import *
(n, k) = map(int, input().split())
a = 2 ** n - 1
if k % 2 == 1:
	print(1)
elif a // 2 + 1 == k:
	print(n)
else:
	for i in range(2, 50):
		if (k + 2 ** (i - 1)) % 2 ** i == 0:
			print(i)
			break


(n, k) = map(int, input().split())
for m in range(1, n + 1):
	if (k - 2 ** (m - 1)) % 2 ** m == 0:
		print(m)
		break


(n, k) = map(int, input().split())
for i in range(50):
	num = i + 1
	inc = pow(2, num)
	if (k + pow(2, i)) % inc == 0:
		print(num)
		break


(n, k) = map(int, input().split())
num = 1
am = 0
while k % num == 0:
	am += 1
	num *= 2
print(am)


(n, k) = [int(i) for i in input().split()]
p = 2 ** n
num = k
counter = n
while num != 0:
	num = abs(num - p // 2)
	p = p // 2
	counter -= 1
print(counter + 1)


(n, k) = map(int, input().split())
q = 1
while k % 2 == 0:
	q += 1
	k //= 2
print(q)


from sys import stdin, stdout
from math import log

def PositionRightmostSetbit(n):
	position = 1
	m = 1
	while not n & m:
		m = m << 1
		position += 1
	return position

def give(n):
	yield b_e(n - 1)
	yield b_e(n)

def main():
	(n, m) = map(int, stdin.readline().strip().split())
	(l, r) = (1, n + 1)
	if m & m - 1 == 0:
		number = int(log(m, 2)) + 1
	else:
		number = PositionRightmostSetbit(m)
	stdout.write(f'{number}')
main()


(n, k) = map(int, input().split())
for i in range(n):
	if k % 2 != 0:
		print(i + 1)
		exit()
	k /= 2


def mexk(n, k):
	ans = n
	low = 1
	high = pow(2, n) - 1
	while low <= high:
		mid = (low + high) // 2
		if mid == k:
			return ans
		ans -= 1
		if k < mid:
			high = mid - 1
		else:
			low = mid + 1
(n, k) = map(int, input().split())
print(mexk(n, k))


(n, k) = map(int, input().split())
ret = 1
while k % 2 == 0:
	k /= 2
	ret += 1
print(ret)


(n, k) = map(int, input().split())
m = 1
k -= 1
for i in range(n - 1):
	m *= 2
	m += 1
m //= 2
result = n
while k != m:
	if k > m:
		k = (k - 1) % m
	m //= 2
	result -= 1
print(result)


(n, k) = list(map(int, input().split()))

def nk(n, k):
	if n == 1:
		return 1
	t = 2 ** (n - 1)
	if k == t:
		return n
	if k < t:
		return nk(n - 1, k)
	else:
		return nk(n - 1, k - t)
print(nk(n, k))


(n, k) = map(int, input().split())
counter = 0
while k % 2 == 0:
	k = k // 2
	counter += 1
print(counter + 1)


import math
(n, k) = map(int, input().split())
cnt = 1
while k % 2 == 0:
	k = k // 2
	cnt += 1
print(cnt)


def find(lvl, ind):
	if lvl == 1 or ind == 1:
		return 1
	elif ind == (dic[lvl] + 1) / 2:
		return lvl
	elif ind <= dic[lvl - 1]:
		return find(lvl - 1, ind)
	elif ind > dic[lvl - 1]:
		return find(lvl - 1, ind - dic[lvl - 1] - 1)
(step, index) = map(int, input().split())
dic = dict()
dic[1] = 1
for i in range(2, step + 1):
	dic[i] = dic[i - 1] * 2 + 1
print(find(step, index))


(n, m) = map(int, input().split())
k = pow(2, n) - 1
lo = 0
hi = k
i = 0
while lo <= hi:
	mid = (lo + hi) // 2
	if mid > m - 1:
		hi = mid - 1
	elif m - 1 > mid:
		lo = mid + 1
	else:
		break
	i += 1
print(n - i)


import math
inp = list(map(int, input().split()))
(N, K) = (inp[0], inp[1])
i = 1
if K % 2 == 1:
	print(1)
else:
	while i <= K:
		if K % i == 0:
			t = K // i
			if (t + 1) % 2 == 0:
				print(int(math.log(i, 2)) + 1)
				break
		i *= 2


(n, k) = map(int, input().split())
k -= 1
s = 0
i = 0
l = 2 ** n - 1
while True:
	if s + int(l / 2) == k:
		print(n - i)
		break
	elif s + int(l / 2) < k:
		s = s + int(l / 2) + 1
		l = int(l / 2)
		i = i + 1
	else:
		i = i + 1
		l = int(l / 2)


(n, k) = map(int, input().split())

def f(n, k):
	t = 2 ** (n - 1)
	if k == t:
		return n
	return f(n - 1, k % t)
print(f(n, k))


(n, k) = [int(x) for x in input().split()]
answer = 1
while k % 2 == 0:
	k = k // 2
	answer += 1
print(answer)


arr = [1]
while len(arr) != 50:
	arr.append(arr[-1] * 2 + 1)
(n, k) = map(int, input().split())
l = arr[n - 1]
while k > 1 and k != l // 2 + 1:
	l = l // 2
	if k > l:
		k -= l + 1
	n -= 1
if k > 1:
	print(n)
else:
	print(1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		(n, k) = LI()
		r = 0
		while 2 ** r & k == 0:
			r += 1
		rr.append(r + 1)
	return JA(rr, '\n')
print(main())


import math
st = ''

def func(n, k):
	n -= 1
	p = pow(2, n)
	if k > p:
		k -= p
	if k & 1:
		return 1
	x = math.log(k, 2)
	p = k & ~(k - 1)
	if x % 1 == 0:
		return int(x + 1)
	p = math.log(p, 2)
	return int(p + 1)
for _ in range(1):
	(n, k) = map(int, input().split())
	st += str(func(n, k)) + '\n'
print(st)


(n, k) = map(int, input().split())
x = bin(k)[2:]
print(len(x) - len(x.strip('0')) + 1)


def input_ints():
	return list(map(int, input().split()))

def solve():
	(y, x) = input_ints()
	for i in range(50):
		if x >> i & 1:
			print(i + 1)
			return
solve()


__author__ = 'Alexander'
(n, k) = map(int, input().split())
if k % 2 == 1:
	print(1)
else:
	val = k
	counter = 0
	while val % 2 != 1:
		val /= 2
		counter += 1
	print(counter + 1)


(n, k) = map(int, input().split())
q = 2 ** n
for i in range(n, -1, -1):
	if k % q == q // 2:
		x = i
		break
	q //= 2
print(x)


import sys

def main():
	(n, k) = map(int, input().split())
	ans = 1
	while k % 2 == 0:
		k /= 2
		ans += 1
	print(ans)
main()


X = list(map(int, input().split()))
while 2 ** (X[0] - 1) != X[1]:
	X[1] %= 2 ** (X[0] - 1)
	X[0] -= 1
print(X[0])


(n, k) = [int(x) for x in input().split()]
if k % 2 == 1:
	print(1)
	exit()
now_num = n
pointer = 2 ** (n - 1)
l = 0
r = 2 ** n
while pointer != k:
	if pointer > k:
		r = pointer
		pointer = (l + r) / 2
		now_num -= 1
	elif pointer < k:
		l = pointer
		pointer = (l + r) / 2
		now_num -= 1
print(now_num)


(n, k) = map(int, input().split())
l = 1
h = 2 ** n
ans = n
while l <= h:
	res = l + (h - l) // 2
	if res == k:
		print(ans)
		break
	elif k < res:
		h = res - 1
	else:
		l = res + 1
	ans -= 1


(n, k) = input().split()
n = int(n)
k = int(k)
ln = 2 ** n - 1
pos = 2 ** (n - 1)
ans = n
while pos != k:
	n -= 1
	pos = 2 ** (n - 1)
	k = abs(ln // 2 + 1 - k)
	ln = 2 ** n - 1
	ans = n
print(ans)


def solve(n, k):
	if n == 1 or k == 1:
		return 1
	if k == 2 ** (n - 1):
		return n
	if k < 2 ** (n - 1):
		return solve(n - 1, k)
	else:
		return solve(n - 1, k - 2 ** (n - 1))
(n, k) = [int(s) for s in input().split()]
print(solve(n, k))


(n, k) = map(int, input().split())
ans = n
lo = 1
hi = 1
for i in range(n - 1):
	hi = hi * 2 + 1
while lo <= hi:
	mid = (lo + hi) // 2
	if mid < k:
		lo = mid + 1
	elif mid > k:
		hi = mid
	else:
		print(ans)
		break
	ans -= 1


(n, k) = map(int, input().split())
k -= 1
if k % 4 == 0 or k % 4 == 2:
	print(1)
elif k % 4 == 1:
	print(2)
else:
	k += 1
	a = 1
	b = 2
	while k % 4 == 0:
		el = k // 4
		k -= el * 3
		a += 2
		b += 2
	if k % 4 == 1 or k % 4 == 3:
		print(a)
	else:
		print(b)


lst = [int(s) for s in input().split()]
capacity = 2 ** lst[0]
lst[0] -= 1
while capacity != lst[1]:
	if lst[1] > capacity:
		capacity += 2 ** lst[0]
		lst[0] -= 1
	else:
		capacity -= 2 ** lst[0]
		lst[0] -= 1
print(lst[0] + 2)


def wk(n, k):
	cn = 2 ** (n - 1)
	if k == cn:
		return n
	elif k < cn:
		return wk(n - 1, k)
	else:
		return wk(n - 1, k - cn)
(n, k) = map(int, input().split())
print(wk(n, k))


(n, k) = [int(x) for x in input().split()]
k = bin(k)
k = reversed(k)
for (i, val) in enumerate(k):
	if val == '1':
		print(i + 1)
		break


import os.path
import sys
from math import *
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def inp():
	return sys.stdin.readline().strip()
(n, k) = map(int, inp().split())
ans = 0
while k % 2 == 0:
	ans += 1
	k //= 2
print(ans + 1)


def getSec(n, k):
	if n == 1:
		return 1
	return getSec(n - 1, k) if k < 1 << n - 1 else n if k == 1 << n - 1 else getSec(n - 1, k - (1 << n - 1))
(n, k) = (int(i) for i in input().split(' '))
print(getSec(n, k))


a = int(input().split()[1])
answer = 1
while a % 2 != 1:
	answer += 1
	a //= 2
print(answer)


(a, b) = list(map(int, input().split()))
s = [[2 ** i, 2 ** (i + 1)] for i in range(0, a + 1)]
for i in range(0, a + 1):
	if (b - s[i][0]) % s[i][1] == 0:
		print(i + 1)
		break


(n, k) = list(map(int, input().split()))
summa = 1
while k % 2 == 0:
	summa += 1
	k = k // 2
print(summa)


def f(k):
	a = [1]
	for i in range(2, k + 1):
		a0 = a[:]
		a.append(i)
		a += a0
	return a

def get_size(n):
	s = 1
	for i in range(1, n):
		s = s * 2 + 1
	return s

def g(n, k):
	s = get_size(n)
	while n > 1:
		s = s // 2
		n -= 1
		if k > s:
			k = (k - 1) % s
			continue
		if k < s:
			continue
		n += 1
		break
	return (n, s, k)
(n, k) = map(lambda x: int(x), input().split(' '))
k -= 1
res = g(n, k)
print(res[0])


def go(l, r, need, alphSize):
	m = l + (r - l) // 2
	if need < m:
		return go(l, m - 1, need, alphSize - 1)
	elif need > m:
		return go(m + 1, r, need, alphSize - 1)
	else:
		return alphSize
(n, k) = map(int, input().strip().split())
size = 1
for i in range(n - 1):
	size = size * 2 + 1
print(go(1, size, k, n))


import math
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
ans = 1
while k % 2 == 0:
	k = k / 2
	ans += 1
print(ans)


(n, k) = map(int, input().split())
if k % 2 == 1:
	print(1)
	exit(0)
if k == 2 ** (n - 1):
	print(n)
	exit(0)
k %= 2 ** (n - 1)
n -= 1
while k != 2 ** (n - 1):
	k %= 2 ** (n - 1)
	n -= 1
print(n)


(n, k) = map(int, input().split())
k -= 1
ans = -1
for i in range(n - 1, -1, -1):
	l = (1 << i) - 1
	if k == l:
		ans = i + 1
		break
	elif k > l:
		k -= l + 1
print(ans)


(_, k) = map(int, input().split())
print(len(bin(k & -k)) - 2)


b = bin(int(input().split()[1]))
print(len(b) - b.rfind('1'))


(n, k) = map(int, input().split())
k1 = bin(k)
i = len(k1) - 1
d = 1
while k1[i] != '1':
	i -= 1
	d += 1
print(d)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())
from bisect import bisect_left
import sys

def fxn(st, en, ind, step):
	mid = st + (en - st) // 2
	if ind < mid:
		return fxn(st, mid - 1, ind, step - 1)
	elif ind > mid:
		return fxn(mid + 1, en, ind, step - 1)
	else:
		return step
(n, k) = map(int, sys.stdin.readline().split())
sz = 0
for i in range(n):
	sz = sz * 2 + 1
ans = fxn(1, sz, k, n)
print(ans)
import sys


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 0
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def solve():
	(n, k) = mi()
	l = 1
	r = pow(2, n) - 1
	while l <= r:
		m = l + (r - l) // 2
		if m == k:
			print(n)
			exit(0)
		n -= 1
		if m > k:
			r = m - 1
		else:
			l = m + 1
solve()


import sys
(n, k) = map(int, sys.stdin.readline().split())
if k % 2 == 1:
	print('1')
else:
	z = 2
	flag = 0
	while z <= n and flag == 0:
		a = 2 ** z
		b = 2 ** (z - 1)
		if k % a == b:
			print(z)
			flag = 1
			break
		z = z + 1


import math
x1 = input().split()
x = int(x1[1])
y = int(x1[0])
while True:
	num = math.log(x, 2)
	if num == 0:
		print('1')
		break
	if round(num, 8) % int(num) == 0:
		if num >= y:
			num -= y
		print(int(num) + 1)
		break
	x = x - 2 ** int(num)


(n, k) = map(int, input().split(' '))
if k % 2 != 0:
	print(1)
	exit()
dlina = 2 ** n - 1
i_right = dlina
i_left = 0
i = k + 1
k -= 1
while i != k:
	i = (i_left + i_right) // 2
	if k > i:
		i_left = i
	else:
		i_right = i
	n = n - 1
print(n + 1)


(n, k) = map(int, input().split())
if k % 2 != 0:
	print(1)
else:
	delim = 2
	cnt = 0
	while True:
		if k % delim == 0:
			cnt += 1
			k //= delim
		else:
			break
	print(cnt + 1)


(n, k) = input().split()
n = int(n)
k = int(k)
result = 1
for i in range(n):
	number = 2 ** i
	test = (k - number) / (2 * number)
	if int(test) == test:
		result = i + 1
		break
print(result)


import math
(n, k) = map(int, input().split())
i = 2
while True:
	if k % i == i // 2:
		ans = math.log2(i // 2) + 1
		print(int(ans))
		exit()
	i *= 2


(n, k) = list(map(int, input().split()))
i = 1
c = 1
while 1 > 0:
	if (k - i) % (2 * i) == 0:
		print(c)
		break
	else:
		c += 1
		i *= 2


(n, k) = map(int, input().split())
res = 1
while k % 2 == 0:
	res += 1
	k //= 2
print(res)


(n, k) = map(int, input().split())
a = 0
while k % 2 == 0:
	a += 1
	k /= 2
print(a + 1)


(n, k) = map(int, input().split())
for i in range(1, n + 2):
	st = 2 ** (i - 1)
	de = 2 ** i
	if (k - st) % de == 0:
		print(i)
		break


(n, k) = map(int, input().split())
t = 2 ** n - 1
while k != (t + 1) // 2:
	n -= 1
	t //= 2
	if k > t:
		k -= t + 1
print(n)


(y, x) = map(int, input().split())
for i in range(50):
	if x >> i & 1:
		print(i + 1)
		break


(n, k) = [int(i) for i in input().split()]
t = 1
while k % 2 == 0:
	k = k // 2
	t += 1
print(t)


import math

def sol(n, k):
	s = 2 ** n - 1
	mid = s // 2
	if k == mid:
		return n
	elif k < mid:
		return sol(n - 1, k)
	else:
		k = 2 * mid - k
		return sol(n - 1, k)
(n, k) = map(int, input().split())
if k % 2:
	print(1)
else:
	print(sol(n, k - 1))


def Main():
	(n, k) = map(int, input().split())
	i = 1
	while k % 2 != 1:
		i += 1
		k //= 2
	print(i)
Main()


I = lambda : list(map(int, input().split()))
(n, k) = I()
k = (k - 1) % 2 ** (n - 1) + 1
print(len(bin(k)) - len(bin(k).strip('0')))


(n, k) = map(int, input().split())
count = 1
while k % 2 == 0:
	count += 1
	k = int(k / 2)
print(count)


s = input().split()
a = int(s[0])
b = int(s[1])
j = 0
c = 1
while b % c == 0:
	j += 1
	c *= 2
print(j)


import sys

def input():
	return sys.stdin.readline().rstrip('\r\n')

def List():
	return list(map(int, input().split()))

def Num():
	return int(input())

def solve():
	(n, k) = List()
	return 2 * k - bin(k).count('1') - (2 * (k - 1) - bin(k - 1).count('1'))
print(solve())


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
dgl = lambda : list(map(int, input()))
il = lambda : list(map(int, input().split()))
(n, k) = f()
print((k & -k).bit_length())


(n, k) = map(int, input().split())
t = 1
while k % 2 == 0:
	t += 1
	k //= 2
print(t)


def main():
	inputs = [int(i) for i in input().split(' ')]
	n = inputs[0]
	k = inputs[1]
	length = 2 ** n - 1
	while True:
		if k == length // 2 + 1:
			print(n)
			return
		else:
			length = length // 2
			k = k % (length + 1)
			n -= 1
main()


(_, k) = map(int, input().split())
a = 1
while k % 2 == 0:
	a += 1
	k //= 2
print(a)


from math import *
(n, k) = map(int, input().split())
i = k & -k
i = int(log2(i))
print(i + 1)


def gt(sz, k, n):
	if sz // 2 == k:
		return n + 1
	return gt(sz // 2, sz // 2 - abs(sz // 2 - k), n - 1)
(n, k) = map(int, input().split())
sz = 1
if k % 2 == 1:
	print(1)
else:
	k -= 1
	for i in range(1, n + 1):
		sz = 2 * sz + 1
	print(gt(sz, k, n))


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
(n, k) = map(int, input().split())
p = k & -k
print(int(math.log2(p)) + 1)


def dfs(n, k):
	if n == 1:
		return 1
	m = 1 << n - 1
	if m == k:
		return n
	if m > k:
		return dfs(n - 1, k)
	return dfs(n - 1, k - m)
(N, K) = map(int, input().split())
print(dfs(N, K))


(n, k) = list(map(int, input().split()))
res = 1
while k & 1 == 0:
	k >>= 1
	res += 1
print(res)


def main():
	(n, k) = map(int, input().split())
	c = 1
	while k % 2 == 0:
		k /= 2
		c += 1
	print(c)
main()


import math
(n, k) = [int(x) for x in input().split()]
print(int(math.log2(k & -k) + 1))


def huhu(n, k):
	maks = 2 ** n
	count = 1
	while maks > k and k > 0:
		if k % 2 == 0:
			count += 1
			k /= 2
		else:
			return count

def main():
	a = input()
	eks = a.split()[0]
	urutan = a.split()[1]
	print(huhu(int(eks), int(urutan)))
main()


(n, k) = map(int, input().split())
i = 1
while not k % 2:
	k /= 2
	i += 1
print(i)


__author__ = 'Alexander'

def f(n, k):
	t = 2 ** (n - 1)
	if k == t:
		return n
	elif k < t:
		return f(n - 1, k)
	else:
		return f(n - 1, k - t)
(n, k) = map(int, input().split())
print(f(n, k))


def solve(position, size, level):
	if position == size // 2:
		return level
	return solve(abs(position - size // 2), size // 2, level - 1)
(n, k) = map(int, input().split())
Size = 2 ** n
print(solve(k, Size, n))


(n, k) = map(int, input().split())
size = 1
for i in range(1, n):
	size = 2 * size + 1
l = 0
h = size
count = n
while l <= h:
	mid = (l + h) // 2
	if mid == k - 1:
		break
	elif mid < k - 1:
		l = mid + 1
	else:
		h = mid - 1
	count -= 1
print(count)


from sys import stdin
(N, K) = map(int, stdin.readline().split())
K -= 1
size = 1
for i in range(N - 1):
	size = size * 2 + 1
while True:
	half = size // 2
	if K == half:
		print(N)
		break
	N -= 1
	if K >= half:
		K = size - K - 1
	size = half


def f(n, k):
	if k == pow(2, n - 1):
		return n
	elif k > pow(2, n - 1):
		k = k - pow(2, n - 1)
		return f(n, k)
	else:
		n -= 1
		return f(n, k)
s = input().split()
n = int(s[0])
k = int(s[1])
print(f(n, k))


(k, n, i) = map(int, input().split(' ') + ['1'])
while n & 1 == 0:
	i += 1
	n = n >> 1
print(i)


(n, k) = map(int, input().split())
if k % 2:
	print('1')
else:
	x = 2 ** (n - 1)
	y = x
	ans = 0
	while x != k:
		if x == k:
			break
		if k > x:
			x += y // 2
		elif x > k:
			x -= y // 2
		ans += 1
		y = y // 2
	print(n - ans)


def main():
	(n, k) = list(map(int, input().split()))
	while n != 0:
		if k == 2 ** (n - 1):
			print(n)
			return
		else:
			k = k % 2 ** (n - 1)
		n -= 1
main()


(n, k) = map(int, input().split())
import math
k -= 1
ans = n + 1
if k % 2 == 0:
	ans = 1
else:
	l = 0
	r = 2 ** n - 1
	while l != k:
		m = (l + r) // 2
		if m > k:
			r = m
		elif m <= k:
			l = m
		ans -= 1
print(ans)


(n, k) = map(int, input().split())
digit = 0
while k % 2 == 0:
	k = k // 2
	digit += 1
print(digit + 1)


(n, k) = map(int, input().split())
d = 2 ** (n - 1)
if k > d:
	k = abs(k - d)
if k % 2 != 0:
	print(1)
else:
	r = 0
	while k != d:
		if d // 2 < k:
			k = abs(k - d)
		d = d // 2
		r = r + 1
	print(n - r)


(n, k) = [int(i) for i in input().split()]
now = 2
step = 1
for i in range(60):
	if (k - now / 2) % now == 0:
		print(step)
		break
	now *= 2
	step += 1


(n, k) = map(int, input().split())

def fun(n, k):
	if n == 1:
		return 1
	if k == 1 << n - 1:
		return n
	elif k < 1 << n - 1:
		return fun(n - 1, k)
	else:
		return fun(n - 1, k - (1 << n - 1))
print(fun(n, k))


from math import *

def binarysearch(l, r, x, val):
	if r >= l:
		mid = l + (r - l) // 2
		if x == mid:
			return val
		elif mid > x:
			val -= 1
			return binarysearch(l, mid - 1, x, val)
		else:
			val -= 1
			return binarysearch(mid + 1, r, x, val)
	else:
		return -1
(n, k) = map(int, input().split())
val = n
r = pow(2, n) - 1
ans = binarysearch(1, r, k, val)
print(ans)


def solve(max_n, k):
	p = 1 << max_n - 1
	for i in range(max_n, 0, -1):
		if k % p == 0:
			return i
			break
		p >>= 1

def bruteforce(max_n):
	a = [1]
	for i in range(2, max_n + 1):
		a = a + [i] + a
	return a

def test(max_n):
	a = bruteforce(max_n)
	for k in range(1, 50):
		assert a[k - 1] == solve(max_n, k), (a[k], solve(max_n, k), k)
(max_n, k) = map(int, input().split())
print(solve(max_n, k))


(n, k) = map(int, input().split())
x = 1
while k % 2 == 0:
	k //= 2
	x += 1
print(x)


(n, k) = map(int, input().split())
k = bin(k)
k = k[2:]
k = k[::-1]
for i in range(len(k)):
	if k[i] == '1':
		print(i + 1)
		exit()


from sys import stdin, stdout
(n, k) = stdin.readline().rstrip().split()
stdout.write(str(bin(int(k))[2:][::-1].index('1') + 1))


(n, k) = map(int, input().split())
now = n
while True:
	if k == 2 ** (now - 1):
		print(now)
		break
	else:
		now -= 1
		k %= 2 ** now


(n, k) = map(int, input().split(' '))
two = 2 ** (n - 1)
value = n
while two != k:
	if two < k:
		k = k - two
	value -= 1
	two = two // 2
print(value)


numero = list(map(int, input().strip().split(' ')))

def juego(n):
	largo = 2 ** n[0] - 1
	j = 1
	indice = n[1]
	while True:
		if indice % 2 != 0:
			print(j)
			break
		else:
			indice = indice / 2
			j += 1
juego(numero)


(n, k) = map(int, input().split())

def f(i, j):
	l = 1 << i - 1
	if j == l:
		return i
	elif j < l:
		return f(i - 1, j)
	else:
		return f(i - 1, l - (j - l))
print(f(n, k))


(n, k) = map(int, input().split())
sz = 2 ** n - 1

def foo(l, r, val, ms):
	m = l + (r - l) // 2
	if val < m:
		return foo(l, m - 1, val, ms - 1)
	elif val > m:
		return foo(m + 1, r, val, ms - 1)
	else:
		return ms
print(foo(1, sz, k, n))


(n, m) = map(int, input().split())
print((m & -m).bit_length())


(n, t) = map(int, input().split())
c = 0
while True:
	if t & 1 == 1:
		print(c + 1)
		break
	else:
		t = t >> 1
		c += 1


import sys
(n, k) = map(int, input().split())
co = 0
p = 1
while k % p == 0:
	co += 1
	p *= 2
print(co)


(n, m) = map(int, input().split())
ans = 1
while m % 2 == 0:
	m /= 2
	ans += 1
print(ans)


a = int(input().split()[1])
s = 1
while not a & 1:
	a -= a // 2
	s += 1
print(s)


def ri():
	return map(int, input().split())
(n, k) = ri()
l = 0
for i in range(n + 1):
	l += 2 ** i
for i in range(n + 1):
	if k == (l - 1) / 2 + 1:
		print(n + 1 - i)
		exit()
	elif k > (l - 1) / 2 + 1:
		k = k - (l - 1) / 2 - 1
	l = (l - 1) / 2


import math
(n, k) = [int(x) for x in input().split()]
A = [0] * 50
for i in range(50):
	A[i] = 2 ** i
if k in A:
	print(round(math.log(k, 2)) + 1)
elif k % 2 == 1:
	print('1')
else:
	i = 1
	while k % A[i] == 0:
		i += 1
	print(i)


(n, k) = map(int, input().split())
s = str(bin(k))
ans = len(s)
for i in range(1, len(s)):
	if s[-i] == '1':
		ans = i
		break
print(ans)


def binary_search(lb, ub, val, cnt):
	mid = (lb + ub) // 2
	if val < mid:
		ub = mid - 1
		binary_search(lb, ub, val, cnt - 1)
	elif val > mid:
		lb = mid + 1
		binary_search(lb, ub, val, cnt - 1)
	else:
		print(cnt)
(n, k) = list(map(int, input().split()))
size = 1
for i in range(1, n):
	size = 2 * size + 1
binary_search(1, size, k, n)


def get_number(k):
	current = 1
	div = 1
	while True:
		if k % div == 0:
			current += 1
			div *= 2
		else:
			return current - 1
inp = input()
(n, k) = inp.split(' ')
print(get_number(int(k)))


k = bin(int(input().split()[1]))
print(len(k) - k.rfind('1'))


(n, k) = map(int, input().split())

def cal(n, k):
	if k == 2 ** (n - 1):
		print(n)
	else:
		cal(n - 1, k % 2 ** (n - 1))
cal(n, k)


def inp():
	return map(int, input().split())

def binary_search(start, end, x, n):
	if end < start:
		return -1
	else:
		mid = start + (end - start) // 2
		if mid == x:
			return n
		elif mid > x:
			return binary_search(start, mid - 1, x, n - 1)
		else:
			return binary_search(mid + 1, end, x, n - 1)
(n, k) = inp()
print(binary_search(1, 2 ** n - 1, k, n))


(n, k) = map(int, input().split())
v = 1
p = 1
for i in range(n - 1):
	p = p * 2
while p != k:
	if k > p:
		k = k - p
	p = p // 2
	n = n - 1
print(n)


import os
import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

def nninp():
	return map(int, input().split())

def llinp():
	return list(map(int, input().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict
(n, k) = nninp()
l1 = [0]
ind = 1
length = 1
for i in range(n):
	l1.append([ind, length + 1])
	ind = length + 1
	length = 2 * length + 1
for i in range(1, n + 1):
	if (k - l1[i][0]) / l1[i][1] % 1 == 0:
		print(i)
		exit()


(n, k) = map(int, input().split())
print(next((i + 1 for i in range(1000) if k & 1 << i)))


import math
(n, k) = map(int, input().split())
if k % 2 != 0:
	print(1)
elif k == math.pow(2, n - 1):
	print(n)
else:
	for i in range(2, n):
		if k % math.pow(2, i) == math.pow(2, i - 1):
			print(i)


def find_K(k):
	t = 1
	while k % 2 == 0:
		k = k // 2
		t += 1
	return t
(_, k) = map(int, input().split())
print(find_K(k))


import sys
(n, k) = list(map(int, input().split()))
v = k
k -= 1
sum = 0
for i in range(1, n + 1):
	if (k - sum) % 2 == 0:
		print(i)
		break
	sum += v // (1 << i)


import functools
(n, k) = [int(i) for i in input().split(' ')]

@functools.lru_cache(10000)
def f(n):
	if n == 1:
		return 1
	else:
		return 2 * f(n - 1) + 1

def find(curr_n, i):
	fcn = f(curr_n)
	if (fcn - 1) / 2 + 1 == i:
		return curr_n
	elif i < fcn / 2:
		return find(curr_n - 1, i)
	else:
		return find(curr_n - 1, i - ((fcn - 1) / 2 + 1))
print(find(n, k))


import string
import math
line = input()
n = int(line.split(' ')[0])
k = int(line.split(' ')[1])

def search(l, r, k, dep):
	mid = (l + r) / 2
	if k == mid or l == r:
		return dep
	if k < mid:
		return search(l, mid - 1, k, dep - 1)
	if k > mid:
		return search(mid + 1, r, k, dep - 1)
print(search(1, pow(2, n) - 1, k, n))


(n, k) = list(map(int, input().split()))
finish = False
length = 1
for i in range(n - 1):
	length = length * 2 + 1
while n != 1:
	gran = length // 2 + 1
	if k == gran:
		print(n)
		finish = True
		break
	if k < gran:
		length = length // 2
		n -= 1
	if k > gran:
		k -= length // 2 + 1
		length = length // 2
		n -= 1
if not finish:
	print(1)


[n, k] = list(map(int, input().split()))

def get(k, n):
	l = 2 ** n - 1
	if l == 1:
		return 1
	if k == l // 2 + 1:
		return n
	elif k <= l // 2:
		return get(k, n - 1)
	else:
		return get(k - (l // 2 + 1), n - 1)
print(get(k, n))


import math
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
(n, m) = M()
if m % 2:
	print(1)
elif m & m - 1 == 0:
	c = 0
	while m % 2 == 0:
		c += 1
		m //= 2
	print(c + 1)
else:
	c = 1
	while c * 2 < m:
		c *= 2
	m -= c
	d = []
	for i in range(1, 51):
		d += [2 ** i]
	ans = 1
	c = 0
	e = {}
	for i in range(2, 51):
		e[2 ** (i - 1)] = i
	for i in range(49, -1, -1):
		if m % d[i] == 0 or (m - d[i]) % d[i] == 0:
			ans = d[i]
			break
	print(e[ans])


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
from collections import *
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def function(arr, size, dp):
	if size == 1 or size == 0:
		return 1
	key = ''.join(map(str, arr[:size]))
	if dp[key]:
		return dp[key]
	output = function(arr, size - 1, dp)
	key = ''.join(map(str, arr[:size - 1]))
	dp[key] = output
	if arr[size - 2] * 10 + arr[size - 1] <= 26:
		output += function(arr, size - 2, dp)
		key = ''.join(map(str, arr[:size - 2]))
		dp[key] = output
	return output

def main():
	(n, k) = mi()
	s = 1
	for i in range(n - 1):
		s += s
	start = 0
	end = 2 * s
	while start <= end:
		if start + s == k:
			break
		elif start + s < k:
			start += s
			s //= 2
			n -= 1
		else:
			end -= s
			s //= 2
			n -= 1
	print(n)
main()


(n, k) = map(int, input().split())
while True:
	g = 2 ** (n - 1)
	if k == g:
		print(n)
		break
	elif k > g:
		k -= g
	n -= 1


from sys import stdin as si
from collections import Counter as c
from functools import reduce

class Solution:

	def bazinga(self, x, a):
		if a == 1:
			return 1
		while a >= 1:
			l = len(bin(a)[2:]) - 1
			m = 1 << l
			a = abs(a - m)
		if a == 0:
			l += 1
		return l
(n, m) = map(int, si.readline().strip().split())
S = Solution()
print(S.bazinga(n, m))


from sys import argv, exit

def get_str():
	return input()

def get_int():
	return int(input())

def get_ints():
	return [int(i) for i in input().split(' ')]

def prnt(*args):
	if '-v' in argv:
		print(*args)
l1 = get_ints()
n = l1[0]
k = l1[1] - 1
i = 1
while k % 2 != 0:
	k = int(k / 2)
	i += 1
print(i)


nk = input().split(' ')
(n, k) = [int(x) for x in nk]
while k != 2 ** (n - 1):
	if k > 2 ** (n - 1):
		k -= 2 ** (n - 1)
	n -= 1
print(n)


def sizeOfIteration(n):
	if n == 1:
		return 1
	return sizeOfIteration(n - 1) * 2 + 1

def elementAtPos(pos, steps):
	modulus = pos % 2
	if modulus == 1:
		return 1
	else:
		counter = 2
		n = 2
		while n < sizeOfIteration(steps):
			difference = n * 2
			if (pos - n) % difference == 0:
				return counter
			counter += 1
			n *= 2
	return -1
(n, k) = (int(x) for x in input().split())
print(elementAtPos(k, n))


(n, k) = map(int, input().split())
p = 1
while not k % 2:
	p += 1
	k //= 2
print(p)


(n, k) = map(int, input().split())
(sz, ans, step, k) = (2 ** n - 1, -1, n, k - 1)
while sz > 0:
	if k == (sz - 1) // 2:
		sz = -1
		ans = step
		break
	elif k > (sz - 1) // 2:
		k -= (sz - 1) // 2 + 1
	sz = (sz - 1) // 2
	step -= 1
print(ans if sz == -1 else 1)


(n, k) = map(int, input().split())
a = len(bin(k).replace('0b', ''))
aa = bin(k).replace('0b', '')
c = int('1' + '0' * (a - 1), 2)
d = int('1' + '0' * a, 2)
m = (c + d) // 2
cn = 0
if aa.count('1') == 1:
	print(a)
else:
	while c <= d:
		cn += 1
		if m < k:
			c = m
			m = (c + d) // 2
		elif m > k:
			d = m
			m = (c + d) // 2
		else:
			break
	print(a - cn)


(n, k) = [int(x) for x in input().split()]

def fun():
	if (k - 1) % 2 == 0:
		return 1
	cont = 1
	for i in range(n):
		if (k - 2 ** cont) % 2 ** (cont + 1) == 0:
			return cont + 1
		cont += 1
print(fun())


import sys
from collections import defaultdict as dd
from collections import deque

def eprint(*args):
	print(*args, file=sys.stderr)
pl = 1
from math import *
import copy
if pl:
	input = sys.stdin.readline

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())
d = []
from bisect import *
from itertools import permutations
from bisect import *
f = [0 for i in range(100)]
for i in range(1, 100):
	if i == 1:
		f[i] = 1
	else:
		f[i] = 2 * f[i - 1] + 1

def rec(n, k):
	if k <= f[n - 1]:
		rec(n - 1, k)
	elif k == f[n - 1] + 1:
		print(n)
	else:
		rec(n - 1, k - f[n - 1] - 1)
(n, k) = mi()
rec(n, k)


import math
(n, k) = map(int, input().split())
if k & 1:
	print('1')
else:
	temp = 2 ** 51
	for i in range(51, 0, -1):
		if k % temp == 0:
			break
		temp >>= 1
	ans = math.floor(math.log2(temp))
	print(ans + 1)


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(l, a, n):
	print(l, a, n)
	for i in range(n - l):
		if a[i:l] == list(sorted(a[i:l])):
			return True
	print('YEAAH')
	return False
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	(n, k) = read()
	low = 1
	high = 2 ** n - 1
	z = n + 1
	while low < high:
		z -= 1
		mid = low + (high - low) // 2
		if k > mid:
			low = mid + 1
		elif k < mid:
			high = mid
		else:
			high = low = mid
			break
	if high == 2 ** n - 1:
		z -= 1
	print(min(z, n))
for _ in range(1):
	solve()


(n, k) = [int(i) for i in input().split()]
res = 0
d = 2 ** n - 1
cur = n
while 1:
	if (d + 1) // 2 == k:
		print(cur)
		break
	cur -= 1
	if k > (d + 1) // 2:
		k = k - (d + 1) // 2
	d = 2 ** cur - 1


def solve(n, k):
	if n == 1 and k == 1:
		return 1
	l = 2 ** n - 1
	mid = l // 2 + 1
	if k == mid:
		return n
	if k < mid:
		return solve(n - 1, k)
	else:
		return solve(n - 1, k - 2 ** (n - 1))
(n, k) = map(int, input().split())
print(solve(n, k))


def f(c, a):
	if a[1] % 2 == 1:
		print(c)
		return 0
	else:
		a[1] = a[1] / 2
		c = c + 1
		f(c, a)
a = [int(i) for i in input().split()]
c = 1
f(c, a)


(a, b) = map(int, input().split())
b -= 1
for i in range(0, 100):
	if b % 2 ** (i + 1) == 2 ** i - 1:
		print(i + 1)


def main():
	(n, k) = map(int, input().split())
	w = 2 ** n
	while k != w:
		if k > w:
			k = w * 2 - k
		w //= 2
		n -= 1
	print(n + 1)
main()


def f(n, k):
	if k == 0:
		return n + 1
	if n == 1:
		return 1
	return f(n - 1, k % 2 ** (n - 1))
(n, k) = (int(z) for z in input().split())
print(f(n, k))


[n, k] = list(map(int, input().strip().split()))
n -= 1
while True:
	k = k % 2 ** n
	if k == 0:
		print(n + 1)
		break
	n -= 1


(n, k) = map(int, input().split())
while k:
	n -= 1
	k %= 2 ** n
print(n + 1)


(n, k) = map(int, input().split())
l = 1
h = 2 ** n - 1
while 1:
	m = (l + h) // 2
	if k == m:
		print(n)
		break
	n -= 1
	if m > k:
		h = m - 1
	else:
		l = m + 1


def fastexp(x, n):
	result = 1
	currentpower = x
	while n > 0:
		if n % 2 == 1:
			result = result * currentpower
		currentpower = currentpower * currentpower
		n = n // 2
	return result
cases = input().split()
n = int(cases[0])
k = int(cases[1])
if k % 2 != 0:
	print(1)
else:
	for i in range(2, n + 1):
		a = fastexp(2, i)
		b = a / 2
		if (k - b) % a == 0:
			print(i)
			break


def rec(depth, pos):
	if pos > 2 ** (depth - 1):
		rec(depth - 1, pos - 2 ** (depth - 1))
	elif pos == 2 ** (depth - 1):
		print(depth)
		return
	else:
		rec(depth - 1, pos)
	return
(n, k) = [int(i) for i in input().split()]
rec(n, k)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
(n, k) = mp()
for i in range(1, n + 1):
	if k % (1 << i) == 1 << i - 1:
		print(i)
		exit()


(n, k) = map(int, input().split())
for i in range(1, n + 1, 2):
	if k % 2 != 0:
		print(i)
		break
	elif k % 4 != 0:
		print(i + 1)
		break
	else:
		k = k // 4


def main():
	(n, k) = map(int, input().split())
	while True:
		pow = 2 ** (n - 1)
		if k == pow:
			print(n)
			return
		else:
			n -= 1
			if k > pow:
				k = 2 * pow - k
main()


(n, k) = [int(x) for x in input().split()]
ln = 2 ** n - 1
while n > 1:
	if k == (ln + 1) // 2:
		break
	elif k < (ln + 1) // 2:
		n -= 1
		ln = (ln - 1) // 2
	else:
		k -= (ln + 1) // 2
		n -= 1
		ln = (ln - 1) // 2
print(n)


(n, k) = [int(p) for p in input().split()]
ele = 1
while k % 2 == 0:
	ele += 1
	k //= 2
print(ele)


(n, k) = map(int, input().split())
if k % 2 == 1:
	print(1)
else:
	power = 51
	while k % 2 ** power != 0:
		power -= 1
	print(power + 1)


(n, k) = list(map(int, input().split()))
if k % 2 == 1:
	print(1)
for i in range(1, n):
	c = (k - 2 ** i) / 2 ** (i + 1)
	if c >= 0 and c == int(c):
		print(i + 1)


(n, k) = [int(item) for item in input().split()]
c = 1
while k % 2 == 0:
	c += 1
	k = k // 2
print(c)


(n, k) = map(int, input().split())
b = n
while True:
	m = k
	if k >= 2 ** (n - 1):
		k = 2 ** n - k
		if m == k:
			break
	n -= 1
for i in range(51):
	if k == 1 << i:
		print(i + 1)
		break


def solve(n, k):
	length = 2 ** n - 1
	if k == length // 2:
		return n
	elif k < length // 2:
		return solve(n - 1, k)
	else:
		return solve(n - 1, k - length // 2 - 1)
(n, k) = map(int, input().split())
if k % 2 == 1:
	print(1)
else:
	print(solve(n, k - 1))


(a, b) = map(int, input().split())
while b != 0:
	(a, b) = (a - 1, b % 2 ** (a - 1))
print(a + 1)


n1 = input()
m = n1.split(' ')
n = int(m[0])
k = int(m[1])
a = n
while k % 2 ** a != 0:
	k = k % 2 ** a
	a -= 1
print(a + 1)


(n, k) = list(map(int, input().split()))
l = 2 ** n - 1
(start, end) = (1, l)
t = n
while start <= end:
	mid = (start + end) // 2
	if mid < k:
		start = mid + 1
	elif mid > k:
		end = mid - 1
	else:
		print(t)
		break
	t = t - 1


(n, k) = map(int, input().split())
print((k & -k).bit_length())


(n, k) = map(int, input().split())
l = 1
r = (1 << n) - 1
res = n
m = (l + r) // 2
while k != m:
	res -= 1
	if k > m:
		l = m + 1
	else:
		r = m - 1
	m = (l + r) // 2
print(res)


def find(n, k):
	mid = 2 ** (n - 1)
	if k == mid:
		return n
	elif k < mid:
		return find(n - 1, k)
	else:
		return find(n - 1, k - mid)
(n, k) = map(eval, input().split())
print(find(n, k))


(n, k) = map(int, input().split())
y = 2 ** n - 1
i = n
k -= 1
l = 0
r = y - 1
while 1:
	x = (l + r) // 2
	if k > x:
		l = x + 1
		i -= 1
	elif k < x:
		r = x - 1
		i -= 1
	else:
		print(i)
		break


import math
(m, n) = map(int, input().split())
while True:
	if n == 1:
		print(1)
		break
	elif n == 2:
		print(2)
		break
	elif n - 2 ** math.floor(math.log2(n)) == 0:
		print(math.floor(math.log2(n)) + 1)
		break
	elif n - 2 ** math.floor(math.log2(n)) < 0:
		n -= 2 ** (math.floor(math.log2(n)) - 1)
	else:
		n -= 2 ** math.floor(math.log2(n))


(n, k) = map(int, input().split())
(l, r) = (0, 2 ** n - 1)
while l < r:
	mid = (l + r) // 2
	if mid == k - 1:
		print(n)
		break
	if mid < k - 1:
		l = mid + 1
	if mid > k - 1:
		r = mid - 1
	n -= 1
else:
	print(n)


def pow_mod(base, exp):
	if exp == 0:
		return 1
	elif exp == 1:
		return base
	elif exp & 1 != 0:
		return base * pow_mod(base * base, exp // 2)
	else:
		return pow_mod(base * base, exp // 2)
(n, k) = map(int, input().split())
t1 = pow_mod(2, n - 1)
if k == t1:
	print(n)
elif k % 2 != 0:
	print('1')
else:
	flag = 1
	while flag == 1:
		if k != t1:
			n = n - 1
			k = max(min(k, t1 - k), min(k, k - t1))
			t1 = t1 // 2
		else:
			flag = 0
			print(n)


(n, k) = map(int, input().split())
mid = 2 ** (n - 1)
c = 0
first = 1
last = 2 ** n - 1
if k % 2 == 1:
	print(1)
	exit()
while first <= last:
	if k == mid:
		break
	elif k > mid:
		first = mid + 1
		c += 1
	elif k < mid:
		last = mid - 1
		c += 1
	mid = (first + last) // 2
print(n - c)


(k, v) = (int(input().split()[1]), 1)
while not k & 1:
	(k, v) = (k >> 1, v + 1)
print(v)


(n, k) = map(int, input().split())
L = 0
R = 2 ** n - 1
while L <= R:
	mid = -1 * (-(L + R) // 2)
	if mid == k:
		print(n)
		break
	elif mid > k:
		R = mid - 1
	else:
		L = mid + 1
	n -= 1


import math
(n, k) = list(map(int, input().split()))
arr = reversed([int(math.pow(2, i)) for i in range(50)])
for (index, num) in enumerate(arr):
	if k % num == 0:
		print(50 - index)
		break


(n, k) = map(int, input().split())
length = 2 ** n - 1
ans = 0
if k == length // 2 + 1:
	print(n)
else:
	for i in range(2, 51):
		if (k - 1 - (2 ** (i - 1) - 1)) % 2 ** i == 0:
			ans = i
			break
	if ans:
		print(ans)
	else:
		print(1)


(n, k) = [int(x) for x in input().strip().split(' ')]
le = 2 ** n - 1

def binsearch(level, le, ind):
	if level == 1:
		return 1
	if ind == le // 2 + 1:
		return level
	if ind > le // 2 + 1:
		ind -= le // 2 + 1
	return binsearch(level - 1, le // 2, ind)
print(binsearch(n, le, k))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def binary_search(lb, ub, val, cnt):
	mid = (lb + ub) // 2
	if val < mid:
		ub = mid - 1
		binary_search(lb, ub, val, cnt - 1)
	elif val > mid:
		lb = mid + 1
		binary_search(lb, ub, val, cnt - 1)
	else:
		print(cnt)

def abs(x):
	return x if x >= 0 else -x
for t in range(1):
	(n, k) = list(map(int, input().split()))
	size = 1
	for i in range(1, n):
		size = 2 * size + 1
	binary_search(1, size, k, n)


def solve(s, n, k, num):
	m = s + (n - s) / 2
	if k == m:
		return num
	elif k < m:
		return solve(s, m - 1, k, num - 1)
	elif k > m:
		return solve(m + 1, n, k, num - 1)
(n, k) = [int(i) for i in input().split()]
print(solve(1, 2 ** n - 1, k, n))


(n, k) = list(map(int, input().split()))
k -= 1
x = 1
while True:
	if k % 2 ** x == 2 ** (x - 1) - 1:
		print(x)
		break
	x += 1


(n, k) = map(int, input().split())
a = ans = 1
while 1:
	if (k - a) % (a * 2) == 0:
		print(ans)
		break
	a *= 2
	ans += 1


(n, k) = map(int, input().split())
ans = 1
while not k % 2:
	k //= 2
	ans += 1
print(ans)


(a, b) = map(int, input().split())
count = 1
if b % 2 == 1:
	print(1)
else:
	while b % 2 == 0:
		count += 1
		b //= 2
	print(count)


(n, k) = map(int, input().split())
soln = 1
while k > 0:
	if k & 1 == 1:
		break
	k = k >> 1
	soln += 1
print(soln)


(y, x) = map(int, input().split())
for i in range(y):
	a = x - 2 ** i
	b = 2 ** (i + 1)
	if a / b >= 0 and a % b == 0:
		print(i + 1)
		break


def bs():
	global n, k
	l = 1
	r = 2 ** n - 1
	while l <= r:
		mid = (l + r) // 2
		if mid == k:
			return n
		if mid < k:
			l = mid + 1
		else:
			r = mid
		n -= 1
(n, k) = map(int, input().split())
print(bs())


def f(lo, hi, k, n):
	m = (lo + hi) // 2
	if k < m:
		return f(lo, m - 1, k, n - 1)
	elif k > m:
		return f(m + 1, hi, k, n - 1)
	else:
		return n + 1
(n, k) = list(map(int, input().split()))
l = 1
for _ in range(n):
	l = l * 2 + 1
print(f(1, l, k, n))


(n, k) = map(int, input().split())
cur = 1
while k % 2 == 0:
	k //= 2
	cur += 1
print(cur)


def f(n, m, k):
	if k == (m + 1) / 2:
		return n
	elif k < (m + 1) / 2:
		return f(n - 1, m // 2, k)
	else:
		return f(n - 1, m // 2, k - (m + 1) / 2)
(n, k) = map(int, input().split())
m = 2 ** n - 1
print(f(n, m, k))


(n, k) = [int(x) for x in input().split()]
i = n
indx = k
while True:
	if indx == 2 ** (i - 1):
		print(i)
		break
	if indx < 2 ** (i - 1):
		i -= 1
		continue
	indx -= 2 ** (i - 1)
	i -= 1


(sh, pos) = map(int, input().split())

def sol(sh, ind):
	cent = (2 ** sh - 1) // 2 + 1
	if ind == cent:
		return sh
	elif ind < cent:
		return sol(sh - 1, ind)
	else:
		return sol(sh - 1, ind - cent)
print(sol(sh, pos))


(n, k) = map(int, input().split())
curStep = 1
curLeng = 1
while curStep < n:
	curLeng = curLeng * 2 + 1
	curStep += 1
pointer = n
while k != curLeng // 2 + 1:
	if k > curLeng // 2 + 1:
		k = curLeng - k + 1
	curLeng = (curLeng - 1) // 2
	pointer -= 1
print(pointer)


from sys import stdin, stdout
from math import gcd
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, k) = mp()
	l = [0, 1]
	if k & 1:
		print(1)
		return
	a = 1
	for i in range(2, 55):
		X = pow(2, a)
		a += 1
		Y = pow(2, a)
		if (k - X) % Y == 0:
			print(i)
			return
for _ in range(1):
	solve()


(n, k) = map(int, input().split())
if n == 1:
	print(1)
elif k % 2:
	print(1)
else:
	k -= 1
	k = k % 2 ** (n - 1)
	m = 2 ** n - 1
	h = n
	(l, r) = (1, m - 2)
	while l <= r:
		g = (l + r) // 2
		if k == g:
			break
		h -= 1
		if k < g:
			r = g - 2
		else:
			l = g + 2
	print(h)


import sys
input = sys.stdin.readline

def main():
	(n, k) = map(int, input().split())

	def bs(l, r, k, n):
		while l <= r:
			m = l + r >> 1
			if m == k:
				return n
			n -= 1
			if m < k:
				k -= m
			r = m - 1
	print(bs(1, (1 << n) - 1, k, n))
main()


import math
(n, k) = map(int, input().split())
i = n - 1
if k % 2 == 1:
	print(1)
	exit()
while True:
	if k > 2 ** i:
		k -= 2 ** i
	if k == 2 ** i:
		break
	i -= 1
print(1 + int(math.log(k, 2)))


def s(n, k):
	if k % 2 == 0:
		return 1
	if n == 1:
		return 1
	mid = 2 ** (n - 1) - 1
	if k == mid:
		return n
	if k > mid:
		k = k - mid - 1
	return s(n - 1, k)
(n, k) = map(int, input().split())
print(s(n, k - 1))


def go(n, m):
	t = 2 ** (n - 1)
	if m == t:
		return n
	elif m < t:
		return go(n - 1, m)
	else:
		return go(n - 1, m - t)
(n, m) = map(int, input().split())
print(go(n, m))


import sys
from math import hypot
N = 0
cos = 0.5
sin = -3 ** 0.5 / 2
type = 0
sqrt2 = 2 ** 0.5
sin45 = 1 / 2 ** 0.5
size_po = 1 / 2 ** 0.5
sin_45 = -sin45
num = [6 / 19, 6 / 19, 11 / 9, 16 / 21, 20 / 32, 22 / 18, 8 / 10]

def make_koch(n, x1, y1, x2, y2, painter):
	if n > 8:
		Window.SpinBox.setValue(8)
		return 0
	if n == 0:
		painter.drawLine(x1, y1, x2, y2)
	else:
		(x3, y3) = ((x2 - x1) / 3 + x1, (y2 - y1) / 3 + y1)
		make_koch(n - 1, x1, y1, x3, y3, painter)
		(x4, y4) = (x2 - (x2 - x1) / 3, y2 - (y2 - y1) / 3)
		make_koch(n - 1, x4, y4, x2, y2, painter)
		(x5, y5) = ((x4 - x3) * cos - (y4 - y3) * sin + x3, (y4 - y3) * cos + (x4 - x3) * sin + y3)
		make_koch(n - 1, x3, y3, x5, y5, painter)
		make_koch(n - 1, x5, y5, x4, y4, painter)

def make_dima_tree(n, x1, y1, x2, y2, painter):
	painter.drawLine(x1, y1, x2, y2)
	if n > 0:
		length = hypot(x2 - x1, y2 - y1)
		sinb = (y2 - y1) / length
		cosb = (x2 - x1) / length
		(x3, y3) = (sin45 * cosb - sin45 * sinb, sin45 * cosb + sin45 * sinb)
		x3 *= size_po * length
		y3 *= size_po * length
		x3 += x2
		y3 += y2
		make_dima_tree(n - 1, x2, y2, x3, y3, painter)
		(x3, y3) = (sin45 * cosb - sin_45 * sinb, sin45 * cosb + sin_45 * sinb)
		x3 *= size_po * length
		y3 *= size_po * length
		x3 += x2
		y3 += y2
		make_dima_tree(n - 1, x2, y2, x3, y3, painter)

def f(n, k):
	m = our[n]
	if m // 2 + 1 == k:
		return n
	return f(n - 1, k % (m // 2 + 1))

def make_dr(n, x1, y1, x2, y2, painter):
	if n == 0:
		painter.drawLine(x1, y1, x2, y2)
	else:
		length = hypot(x2 - x1, y2 - y1)
		sinb = (y2 - y1) / length
		cosb = (x2 - x1) / length
		x2 -= x1
		y2 -= y1
		x3 = sin45 * cosb - sin45 * sinb
		y3 = sin45 * cosb + sin45 * sinb
		x3 *= size_po * length
		y3 *= size_po * length
		x3 += x1
		y3 += y1
		x2 += x1
		y2 += y1
		make_dr(n - 1, x1, y1, x3, y3, painter)
		make_dr(n - 1, x3, y3, x2, y2, painter)

def make_dr2(n, x1, y1, x2, y2, painter):
	if n == 0:
		painter.drawLine(x1, y1, x2, y2)
	else:
		length = hypot(x2 - x1, y2 - y1)
		sinb = (y2 - y1) / length
		cosb = (x2 - x1) / length
		x2 -= x1
		y2 -= y1
		x3 = sin45 * cosb - sin45 * sinb
		y3 = sin45 * cosb + sin45 * sinb
		x3 *= size_po * length
		y3 *= size_po * length
		x3 += x1
		y3 += y1
		x2 += x1
		y2 += y1
		make_dr2(n - 1, x1, y3, x3, y1, painter)
		make_dr2(n - 1, x3, y2, x2, y3, painter)

def make_dr3(n, x1, y1, x2, y2, painter):
	if n == 0:
		painter.drawLine(x1, y1, x2, y2)
	else:
		length = hypot(x2 - x1, y2 - y1)
		sinb = (y2 - y1) / length
		cosb = (x2 - x1) / length
		x2 -= x1
		y2 -= y1
		x3 = sin45 * cosb - sin45 * sinb
		y3 = sin45 * cosb + sin45 * sinb
		x3 *= size_po * length
		y3 *= size_po * length
		x3 += x1
		y3 += y1
		x2 += x1
		y2 += y1
		make_dr3(n - 1, x1, y1, x3, y3, painter)
		make_dr3(n - 1, x2, y2, x3, y3, painter)
our = [0, 1]
(n, k) = map(int, input().split())

class MyWidget:

	def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)
		self.depth = N

	def paintEvent(self, event):
		painter = QtGui.QPainter()
		painter.begin(self)
		if type == 0:
			make_koch(self.depth, 10, self.height() - 10, self.width(), self.height() - 10, painter)
		elif type == 1:
			make_dima_tree(self.depth, self.width() / 2, self.height(), self.width() / 2, self.height() / 2, painter)
		elif type == 2:
			make_birch(self.depth, self.width() / 4, self.height() - 170, self.width() / 4, self.height() / 2.5, painter)
		elif type == 3:
			make_tree(self.depth, self.width() / 2, self.height() - 10, self.width() / 2, self.height() * 2 / 3, painter)
		elif type == 4:
			make_dr(self.depth, self.width() / 3.7, self.height() / 4.1, self.width() / 3.7 * 2.7, self.height() / 4.1, painter)
		elif type == 6:
			make_dr3(self.depth, self.width() / 4.8, self.height() / 2.5, self.width() / 6 * 5, self.height() / 2.5, painter)
		elif type == 5:
			make_dr2(self.depth, self.width() / 55, self.height() / 4.7, self.width() / 55 * 54, self.height() / 4.7, painter)
		painter.end()

	def setValue(self, depth):
		if depth > 19:
			Window.SpinBox.setValue(19)
		if self.depth != depth:
			self.depth = depth
			self.repaint()
while len(our) <= n + 1:
	our.append(our[-1] * 2 + 1)
print(f(n, k))

class MyWindow:

	def __init__(self, parent=None):
		QtGui.QMainWindow.__init__(self, parent)
		self.resize(1910, 610)
		self.setWindowTitle('Painter demo')
		self.Widget = MyWidget(self)
		self.Widget.setGeometry(0, 0, 1900, 600)
		self.setMinimumSize(300, 300)
		self.SpinBox = QtGui.QSpinBox(self)
		self.SpinBox.setGeometry(10, 10, 100, 30)
		QtCore.QObject.connect(self.SpinBox, QtCore.SIGNAL('valueChanged(int)'), self.Widget.setValue)
		self.SpinBox.setValue(5)
		self.b = QtGui.QComboBox(self)
		self.b.addItem('Прямая Коха')
		self.b.addItem('Модифицированное дерево')
		self.b.addItem('Неведомая берёза')
		self.b.addItem('Дерево')
		self.b.addItem('Кривая Леви')
		self.b.addItem('Ваза')
		self.b.addItem('Кривая Дракона')
		self.b.setGeometry(130, 10, 250, 30)
		QtCore.QObject.connect(self.b, QtCore.SIGNAL('currentIndexChanged(int)'), self.temp)
		self.b.setCurrentIndex(5)

	def temp(self, a):
		global type
		type = self.b.currentIndex()
		self.resizeEvent(0)
		self.Widget.repaint()

	def resizeEvent(self, event):
		Y = self.height()
		X = self.width()
		dx = 0
		dy = 0
		cons = num[type]
		if Y / X > cons:
			dy = (Y - X * cons) / 2
			Y = X * cons
		elif Y / X < cons:
			dx = (X - Y / cons) / 2
			X = Y / cons
		self.Widget.setGeometry(dx, dy, X, Y)


(n, k) = map(int, input().split())
from math import log
ans = n
while k:
	ans -= 1
	k %= 2 ** ans
print(ans + 1)


from sys import stdin
A = list(map(int, stdin.readline().split()))
n = A[0]
k = A[1]
while True:
	temp = 2 ** n - 1
	if k == int(2 ** (n - 1)):
		print(n)
		break
	elif k > int(2 ** (n - 1)):
		k = 2 ** n - k
	n -= 1
	if n == 1:
		print(1)
		break


(n, p) = map(int, input().split())
if p % 2 == 1:
	print(1)
else:
	ans = 1
	while 1:
		if p % 2 == 1:
			break
		else:
			p = p // 2
			ans += 1
	print(ans)


def sequenceLengthAtStep(step):
	if step == 1:
		return 1
	return sequenceLengthAtStep(step - 1) * 2 + 1

def elementAtPos(pos, steps):
	sequenceLength = sequenceLengthAtStep(steps)
	integer = 1
	posOfFirstDigit = 1
	while posOfFirstDigit < sequenceLength:
		elementModulus = posOfFirstDigit * 2
		if (pos - posOfFirstDigit) % elementModulus == 0:
			return integer
		integer += 1
		posOfFirstDigit *= 2
	return integer
(steps, pos) = (int(x) for x in input().split())
print(elementAtPos(pos, steps))


bin_pow = [0] * 50
bin_pow[0] = 1
for i in range(1, len(bin_pow)):
	bin_pow[i] = bin_pow[i - 1] * 2
(n, k) = map(int, input().split())
for i in range(len(bin_pow) - 1, -1, -1):
	if k % bin_pow[i] == 0:
		print(i + 1)
		break


(n, k) = map(int, input().split(' '))
count = 1
while k & 1 != 1:
	k = k >> 1
	count += 1
print(count)


(n, k) = map(int, input().split())

def solve(n, k):
	v = 2 ** (n - 1)
	if k == v:
		return n
	if k > v:
		return solve(n - 1, k - v)
	else:
		return solve(n - 1, k)
print(solve(n, k))


s = list(map(int, input().split()))
n = s[0]
k = s[1]
while 1:
	if 2 ** n // 2 == k:
		print(n)
		break
	if 2 ** (n - 1) > k:
		n -= 1
	if k > 2 ** (n - 1):
		k = 2 ** n - k
		n -= 1


import bisect
(n, k) = map(int, input().split())
if k % 2 != 0:
	print(1)
elif k % 8 == 0:
	i = 1
	while k % 2 != 1:
		i += 1
		k = k // 2
	print(i)
elif k % 4 == 0:
	print(3)
else:
	print(2)


array = [0]
for i in range(1, 51):
	array.append(array[-1] * 2 + 1)

def solve(n, k):
	global array
	if k == array[n] // 2 + 1:
		return n
	else:
		return solve(n - 1, k % (array[n] // 2 + 1))
(n, k) = [int(i) for i in input().split()]
print(solve(n, k))


(n, k) = map(int, input().split())
s = 0
while not k % 2:
	s += 1
	k //= 2
print(s + 1)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
series = [1]
for i in range(51):
	series.append(2 * series[-1] + 1)
(n, k) = value()
elements = series[n]
ans = n + 1
low = 1
high = elements
while low <= high:
	mid = (low + high) // 2
	if k == mid:
		break
	elif k < mid:
		high = mid - 1
	else:
		low = mid + 1
	ans -= 1
print(ans)


(n, k) = tuple(map(int, input().split()))

def u_n(n):
	return 2 ** (n + 1) - 1

def res(n, k):
	if n == 0:
		return 1
	l = u_n(n - 2)
	if k <= l:
		return res(n - 1, k)
	elif k > l + 1:
		return res(n - 1, k - l - 1)
	else:
		return n
print(res(n, k))


from math import log2
(n, k) = map(int, input().split())
ls1 = []
for i in range(int(log2(k)) + 1):
	if k >> i & 1:
		ls1.append(i)
print(min(ls1) + 1)


import sys
import math

def calculate(lines):
	(n, k) = [int(i) for i in lines[0].split()]
	for test_base in range(int(math.log(k, 2)) + 1, 0, -1):
		if k % pow(2, test_base) == pow(2, test_base - 1):
			return test_base
print(calculate(sys.stdin.readlines()))


(n, k) = map(int, input().split())
if pow(2, n) // 2 == k:
	print(n)
else:
	l = 1
	u = pow(2, n) - 1
	ans = n
	while l <= u:
		mid = (l + u) // 2
		if mid == k:
			print(ans)
			break
		elif mid < k:
			l = mid + 1
		elif mid > k:
			u = mid - 1
		ans -= 1


def solve(n, k):
	if k & 1:
		return 1
	i = 2
	while True:
		if (k - 2 ** (i - 1)) % 2 ** i == 0:
			return i
		i += 1
(n, k) = map(int, input().split())
print(solve(n, k))


(n, k) = [int(i) for i in input().split()]
counter = 1
while True:
	if k % 2 == 1:
		print(counter)
		break
	else:
		k /= 2
		counter += 1


string = input()
numbers = string.split()
a = int(numbers[1])
n = 0
while a % 2 == 0:
	a /= 2
	n += 1
print(n + 1)


(n, k) = map(int, input().split())
if k % 2 == 1:
	print(1)
else:
	mid = 2 ** (n - 1)
	if k == mid:
		print(n)
	else:
		if k < mid:
			t = k
		else:
			t = 2 ** (n - 1) - k
		p = 0
		while t % 2 == 0:
			p += 1
			t = t // 2
		print(p + 1)


import math
(n, k) = map(int, input().split())

def calc(k):
	L = 0
	R = 2 ** n
	M = L + R // 2
	ans = 0
	while k != M:
		if k > M:
			L = M
		else:
			R = M
		M = (L + R) // 2
		ans += 1
	print(n - ans)
calc(k)


(n, k) = map(int, input().split())
st = 1
end = 2 ** n - 1
if k % 2 == 1:
	print(1)
else:
	while 1:
		mid = (st + end) // 2
		if mid == k:
			print(n)
			break
		elif k > mid:
			st = mid + 1
		else:
			end = mid - 1
		n -= 1


(n, k) = [int(a) for a in input().split(' ')]
k -= 1
size = [0]
while size[-1] < k:
	size.append(size[-1] * 2 + 1)
while k != size[-1]:
	pop = size.pop()
	if k > pop:
		k -= pop + 1
print(len(size))


(n, k) = map(int, input().split())

def dfs(q, d):
	q = q % 2 ** (d - 1)
	if q == 0:
		print(d)
	else:
		dfs(q, d - 1)
dfs(k, n)


def solveQ1(n, a, b, s):
	if s[a - 1] == s[b - 1]:
		return 0
	c = s[b - 1]
	n = len(s)
	min_dist = n
	for i in range(n):
		if s[i] == c:
			min_dist = min(abs(a - 1 - i), min_dist)
	return min_dist
(n, k) = list(map(lambda i: int(i), input().split(' ')))

def solveQ2(n, k):
	if n == 1:
		return 1
	if k == pow(2, n - 1):
		return n
	if k > pow(2, n - 1):
		return solveQ2(n - 1, k - pow(2, n - 1))
	else:
		return solveQ2(n - 1, k)
print(solveQ2(n, k))


import bisect as bi
(n, k) = map(int, input().split())
print(len(bin(k & -k)) - 2)


(n, k) = map(int, input().split())
masks = [(1 << i) - 1 for i in range(1, n + 1)]
i = n
while i and masks[i - 1] + 1 != k:
	if masks[i - 1] + 1 < k:
		k = k - masks[i - 1] - 1
	i -= 1
print(i + 1)


def go(l, u, n, k):
	x = l + (u - l) // 2
	if k < x:
		return go(l, x - 1, n - 1, k)
	elif k > x:
		return go(x + 1, u, n - 1, k)
	else:
		return n
(n, m) = map(int, input().split())
l = pow(2, n) - 1
print(go(1, l, n, m))


(N, K) = map(int, input().split())
L = [0] * 60
L[1] = 1
for i in range(2, 60):
	L[i] = 2 * L[i - 1] + 1

def calc(n, k):
	if k == L[n] // 2:
		return n
	elif k > L[n] // 2:
		return calc(n - 1, k - L[n] // 2 - 1)
	else:
		return calc(n - 1, k)
print(calc(N, K - 1))


def ans(l, r, n, k):
	m = l + (r - l) // 2
	if m == k:
		return n
	if m < k:
		return ans(m + 1, r, n - 1, k)
	else:
		return ans(l, m - 1, n - 1, k)
(n, k) = map(int, input().split())
print(ans(1, 2 ** n - 1, n, k))


(n, k) = map(int, input().split())
if k % 2 == 1:
	print(1)
else:
	for i in range(1, 51):
		if k % pow(2, i) == pow(2, i - 1):
			print(i)


import math
(n, k) = [int(x) for x in input().split()]
if k % 2 != 0:
	print(1)
else:
	st = math.log(k, 2)
	if st.is_integer():
		print(int(1 + st))
	else:
		flag = True
		pr = int(st)
		while flag:
			if k % 2 ** pr == 0:
				print(int(1 + pr))
				flag = False
			else:
				pr -= 1