How does the shadow banking system respond to changes in capital regulation of commercial banks? We propose a quantitative general equilibrium model with regulated and unregulated banks to study the unintended consequences of regulation. Tighter capital requirements for regulated banks cause higher convenience yield on debt of all banks, leading to higher shadow bank leverage and a larger shadow banking sector. At the same time, tighter regulation eliminates the subsidies to commercial banks from deposit insurance, reducing the competitive pressures on shadow banks to take risks. The net effect is a safer financial system with more shadow banking. Calibrating the model to data on financial institutions in the US, the optimal capital requirement is around 16%%.