import math


def _n_relabels(y, s):
    """Compute the number of promotions/demotions that need to occur.

    :param np.array y: target labels
    :param np.array s: protected class labels
    :returns: number of promotions/demotions to occur.
    :rtype: int
    """
    total = float(len(s))
    s1 = s.sum()
    s0 = total - s1
    s1_positive = ((s == 1) & (y == 1)).sum()
    s0_positive = ((s == 0) & (y == 1)).sum()
    return int(math.ceil(((s1 * s0_positive) - (s0 * s1_positive)) / total))