Why did Japan surrender?

The Enola Gay an American plane dropped two Atomic Bombs the first one on the 6th of August on Hiroshima, then the second on Nagasaki three days later.