def integer(number):
    """Returns an integer whatever the input value
    
    If the input is invalid returns 0

    >>> integer("tonsils")
    0
    >>> integer(4.5)
    4
    >>> integer(32)
    32
    >>> integer("-15.1")
    -15
    >>> integer(22.499999999)
    22
    >>> integer("22.5")
    22
    >>> integer("-red")
    0
    """
    try:
        x = round(float(number))
    except ValueError:
        x = 0
    return x