Zoom level 0 is 1 tile. (1 x 1)
Zoom level 1 is 4 tiles. (2 x 2)
Zoom level 2 is 16 tiles. (4 x 4)
Zoom level 3 is 64 tiles. (8 x 8)
Zoom level 4 is 256 tiles (16 x 16)
The x and y counts are doubled for each zoom level. I hope you can do the rest of the math through zoom level 18. To save space, ocean tiles aren't stored. They're created as a response to the request.
At zoom level 3, the tiles are numbered from 0 to 7 in the x direction (longitude) and numbered from 0 to 7 in the y direction (latitude).
The tiles start on the American side of near the International Date Line (longitude -180 or +180). The tile 0,0 starts at about latitude 70 north.
See the Wikipedia article Mercator Projection for more details about how a sphere is mapped to a plane. The calculations for converting longitude and latitude to x and y coordinates are in the Wikipedia article.
You can map any point on the Mercator Projection to a tile set. A tile set is the set of tiles at a zoom level. You have to know the zoom level to know which tile set to access and to calculate which tile in the tile set to retrieve and display.