import re


def parse_asn(asn):
    """Parse a string containing an autonomous system number, returning the
    autonomous system number as int."""
    try:
        return int(asn)
    except ValueError:
        pass
    m = re.match("[aA][sS]([0-9]+)$", asn)
    if m:
        return int(m[1])