import re


def extract_redundancy_factor(oclass):
    """Extract the redundancy factor from an object class.

    Args:
        oclass (str): the object class.

    Returns:
        int: the redundancy factor.

    """
    match = re.search("EC_[0-9]+P([0-9])+", oclass)
    if match:
        return int(match.group(1))
    match = re.search("RP_([0-9]+)", oclass)
    if match:
        return int(match.group(1)) - 1
    return 0