def get_tl_num_size(val: int) -> int:
    """
    Calculate the length of a TL variable.

    :param val: an integer standing for Type or Length.
    :return: The length of var.
    """
    if val <= 0xFC:
        return 1
    elif val <= 0xFFFF:
        return 3
    elif val <= 0xFFFFFFFF:
        return 5
    else:
        return 9