row_cache = []
import bisect

def next_row(x, i):
    if i < len(row_cache): return row_cache[i]
    arr: list = [1]
    for c in range(1, (i + 1) // 2):
        arr.append(x[c - 1] + x[c])
    if i > 0:
        arr.append(2 * x[-1] if i % 2 != 0 else x[-1] + x[-2])
    row_cache.append(arr)
    return arr


num_of_req = int(input())

for _ in range(num_of_req):
    to_find = int(input())
    x = [1]
    i = 0
    while True:
        x = next_row(x, i)
        i += 1
        place = bisect.bisect_left(x, to_find)
        if place != len(x) and x[place] == to_find:
            break

    print(i if i == 1 else i + 1)
