def ott_str_as_int(o):
    """Returns the OTT Id `o` as an integer if `o` is an integer or a string starting with ott (case-insensitive).

    Raises a ValueError if the string does not match ^(OTT)?[0-9]+$
    """
    if isinstance(o, int):
        return o
    if o.startswith('ott'):
        return int(o[3:])
    try:
        return int(o)
    except:
        if o.lower().startswith('ott'):
            return int(o[3:])
        raise