  The sequence $(x_n)_{n\in\mathbb N} = (2,5,15,51,187,\dots)$ given by the
rule $x_n=(2^n+1)(2^{n-1}+1)/3$ appears in several seemingly unrelated areas of
mathematics. For example, $x_n$ is the density of a language of words of length
$n$ with four different letters. It is also the cardinality of the quotient of
$(\mathbb Z_2\times \mathbb Z_2)^n$ under the left action of the special linear
group $\mathrm{SL}(2,\mathbb Z)$. In this paper we show how these two
interpretations of $x_n$ are related to each other. More generally, for prime
numbers $p$ we show a correspondence between a quotient of $(\mathbb
Z_p\times\mathbb Z_p)^n$ and a language with $p^2$ letters and words of length
$n$.
