import math


def get_n(k, e, n_max):
    """
    TS 38.212 section 5.3.1
    """
    cl2e = math.ceil(math.log2(e))
    if (e <= (9/8) * 2**(cl2e - 1)) and (k / e < 9 / 16):
        n1 = cl2e - 1
    else:
        n1 = cl2e
    r_min = 1 / 8
    n2 = math.ceil(math.log2(k / r_min))
    n_min = 5
    n = max(min(n1, n2, n_max), n_min)
    return 2**n