Why Does Japan Have So Many Last Names Compared to China and Korea?

Why does Japan have hundreds of thousands of surnames while China and Korea rely on a handful? The answer lies in a Meiji-era law.