Jump 1, 2, 4, 8, ... slots until you pass x, then binary search the last jump.
This interactive visualization needs JavaScript.