import re


def get_prefixlength(ip):
    """Returns the length of the network prefix, in bits."""

    regex = r'(\d+)[.](\d+)[.](\d+)[.](\d+)[/](\d+)'
    if not re.findall(regex, ip):
        return ip

    p = re.split(regex, ip)
    return int(p[5])