def nat(x):
    """Smart constructor for naturals

    Arg
        x: any literal
    Returns:
        natural value
    Raises:
        ValueError if x cannot be converted into int
        or the result of this conversation is negative
    """
    try:
        n = int(x)
    except Exception as ex:
        raise ValueError("invalid literal for nat()")
    if n < 0:
        raise ValueError("invalid literal for nat()")
    return n