Exact baryon and strangeness conservation in hadronic gas models