def run_Q_operator(qubits, circuit, shots):
    """Execution of the quantum circuit for a step in the used amplitude estimation algorithm.
    Args:
        qubits (int): number of qubits used for the unary basis.
        circuit (Circuit): quantum circuit that performs the m=iterations step of the iterative
            amplitude estimation algorithm.
        shots (int): number of shots to be taken in intermediate steps of the AE algorithm.

    Returns:
        ones (int): number of measured ones after post-selection.
        zeroes (int): number of measured zeroes after post-selection.
    """
    job_payoff_sim = circuit(nshots=shots)
    counts_payoff_sim = job_payoff_sim.frequencies(binary=True, registers=False)
    ones = 0
    zeroes = 0
    for key in counts_payoff_sim.keys():
        unary = 0
        for i in range(0, qubits):
            unary += int(key[i])
        if unary == 1:
            if int(key[qubits]) == 0:
                zeroes += counts_payoff_sim.get(key)
            else:
                ones += counts_payoff_sim.get(key)
    return ones, zeroes