def sequenceLength(n: int) -> int:
    global lengths
    if (n not in lengths):
        if ((n % 2) == 0):
            lengths[n] = (sequenceLength((n // 2)) + 1)
        else:
            lengths[n] = (sequenceLength(((3 * n) + 1)) + 1)
    return lengths[n]
def sequenceLength(n: int) -> int:
    global lengths
    if (n not in lengths):
        if ((n % 2) == 0):
            lengths[n] = (sequenceLength((n // 2)) + 1)
        else:
            lengths[n] = (sequenceLength(((3 * n) + 1)) + 1)
    return lengths[n]