Optimal Security Investments in a Prevention and Detection Game