Mutex and Semaphore Train Analogy

I understand that a mutex allows only one task to access a resource at a time. However, I’m having difficulty grasping how semaphores permit multiple tasks, up to a certain limit, to access a shared resource simultaneously