Where can I connect the unused input to preserve the logic expression?
when we connect it to the +5V supply or E, we can get 0 or 1 as an
output. Connecting it to E makes it work like it is a two-input NAND
gate. I know I have to choose one of them but which one.

You could do it either way and the logic would work the same. So why choose one over the other?

With 2 inputs connected together the signal loading is increased. This could be a problem if the signal driver is close to its fan-out limit.

Unused inputs wired to Ground or V+ should take a short route directly to the IC's own supply pin, to avoid possible EMI and supply voltage differences. Many ICs have an input voltage limit of ~0.3V above and below the supply lines, which can easily occur on large boards with high current draw. If the IC is in a socket or breadboard then the supply pin might accidentally become disconnected, causing the IC to draw full supply current through the unused input's protection diode.

Connecting adjacent pins usually makes PCB routing easier. In your case you have the obvious choice of connecting pin 13 to pin 14 for logic high and using pins 1 and 2 for inputs, or doing it according to your wiring diagram. Until you route the PCB you won't know which one is more convenient.


In more complex circuits with dense layouts it is quite common to see signals routed to different pins than expected. For example a data bus might be wired 'randomly' to a bus buffer or RAM chip because it doesn't care which bit is which. PCB layout programs often have 'pin-swap' and 'gate-swap' functions which allow the PCB designer to easily optimize the layout.