import ipaddress


def netmask_to_prefixlen(netmask: str) -> int:
    """ Takes an IP netmask and returns the corresponding prefix length

    :param str netmask: IP netmask (e.g. 255.255.0.0)
    :return: prefix length
    """
    return ipaddress.ip_network('0.0.0.0/{}'.format(netmask)).prefixlen