In this Rapid Communication, we consider the open problem of the minimum cost of two-qubit gates for simulating the Toffoli gate and show that five two-qubit gates are necessary. Before our work, it was known that five two-qubit gates are sufficient to implement the Toffoli gate, and numerical evidence indicates that five two-qubit gates are also necessary. The idea introduced here can also be used to solve the problem of optimal simulation of Deutsch three-qubit gates. Since quantum computation provides the possibility of solving certain problems much faster than any classical computer using the best currently known algorithms [1][2][3][4][5], a huge amount of effort has been devoted to building functional and scalable quantum computers over the last two decades. The quantum circuit model is one popular model of quantum computer hardware [6][7][8][9][10][11][12][13][14][15][16][17][18]. In order to be a general purpose computational device, a quantum computer must implement a small set of quantum logical gates [14], which are universal, that is, can serve as the basic building blocks of quantum circuits, in the same way as do classical logical gates for conventional digital circuits. It is quite natural to choose certain gates operating on a small number of qubits as the basic gates.Theoretically, any two-qubit gate that can create entanglement, like the controlled-NOT (CNOT) gate, together with all single-qubit gates, is universal [18]. It has also been experimentally demonstrated that two-qubit gates can be realized with high fidelity using the current technology, for example, two-qubit gates with superconducting qubits have been presented with fidelities higher than 90% [19]. Finding more efficient ways to implement quantum gates may allow small-scale quantum computing tasks to be demonstrated on a shorter time scale. More precisely, it would be quite helpful for defeating quantum decoherence to realize multiqubit gates with the least number of possible basic gates. Thus an important problem is how to implement multiqubit gates using only two-qubit gates. Indeed, a study of the minimum cost of two-qubit gates for simulating a multiqubit gate is not only of theoretical importance, but also an experimental requirement: to accomplish a quantum algorithm, even at a small size, one has to implement a relatively high level of control over the multiqubit quantum system. A lot of experiments demonstrate multiqubit controlled-NOT gates in ion traps [20] Making controlled unitaries is an essential task for many algorithms in quantum computing [1]. Among all quantum controlled gates, those highly controlled unitaries (i.e., unitaries controlled on more than one other qubit) are useful in numerous quantum algorithms including the oracle in the * nengkunyu@gmail.com binary welded tree algorithm [5] and quantum simulation [24]. The Toffoli gate is perhaps one of the most important highly controlled unitaries for three reasons: (1) The Toffoli gate is universal for classical reversible computation in the sense that all con...