To solve hospital overcrowding, think like a mathematician