Statistics of energy levels in Hamiltonian systems with classically chaotic dynamics belong to one of three Wigner-Dyson symmetry classes. By the semiclassical approach this remarkable universality can be attributed to the systematic correlations between actions of periodic orbits. The correlating periodic orbits do not exist as independent individuals but rather come in closely packed bunches. We demonstrate how this bunching phenomena can be rigorously described using symbolic dynamics of the system. For systems with Markov partition we introduce an ultrametric distance between periodic orbits and organize them into clusters. Each cluster is composed of periodic orbits passing through (approximately) the same points of the phase space. We then study the distribution of cluster sizes in the asymptotic limit of long trajectories. In the case of the baker's map this problem turns out to be equivalent to the one of counting degeneracies in the length spectrum of de Bruijn graphs.