Turns of wire round the nail, or in the coil the magnet is pushed into.
The current through the wire wound round the nail.
Explore
Wind wire round an iron nail and switch on. Change the turns and the current until it holds 10 pins.