  Let $A^*$ denote the free monoid generated by a finite nonempty set $A.$ In
this paper we introduce a new measure of complexity of languages $L\subseteq
A^*$ defined in terms of the semigroup structure on $A^*.$ For each $L\subseteq
A^*,$ we define its {\it cost} $c(L)$ as the infimum of all real numbers
$\alpha$ for which there exist a language $S\subseteq A^*$ with
$p_S(n)=O(n^\alpha)$ and a positive integer $k$ with $L\subseteq S^k.$ We also
define the {\it cost dimension} $d_c(L)$ as the infimum of the set of all
positive integers $k$ such that $L\subseteq S^k$ for some language $S$ with
$p_S(n)=O(n^{c(L)}).$ We are primarily interested in languages $L$ given by the
set of factors of an infinite word $x=x_0x_1x_2\cdots \in A^\omega$ of zero
topological entropy, in which case $c(L)<+\infty.$ We establish the following
characterisation of words of linear factor complexity: Let $x\in A^\omega$ and
$L=$Fac$(x)$ be the set of factors of $x.$ Then $p_x(n)=\Theta(n)$ if and only
$c(L)=0$ and $d_c(L)=2.$ In other words, $p_x(n)=O(n)$ if and only if
Fac$(x)\subseteq S^2$ for some language $S\subseteq A^+$ of bounded complexity
(meaning $\limsup p_S(n)<+\infty).$ In general the cost of a language $L$
reflects deeply the underlying combinatorial structure induced by the semigroup
structure on $A^*.$ For example, in contrast to the above characterisation of
languages generated by words of sub-linear complexity, there exist non
factorial languages $L$ of complexity $p_L(n)=O(\log n)$ (and hence of cost
equal to $0)$ and of cost dimension $+\infty.$ In this paper we investigate the
cost and cost dimension of languages defined by infinite words of zero
topological entropy.
