Text this: Optimal resource allocation for two-stage connectionless access with collision detection