Let $X$ denote a set and $F_{\mathbf{Mon}}X$ denote the free monoid on $X$.
Call a word $w \in F_{\mathbf{Mon}}X$ non-repeating iff for all words $x,y,z \in F_{\mathbf{Mon}}X,$ we have:
$$w = xy^2 z \rightarrow y = 1$$
For example, if $X = \{a,b\}$, then the non-repeating words in $F_{\mathbf{Mon}}X$ are:
$$\{1,a,b,ab,ba,aba,bab\}$$
It turns out that if $X$ is finite, then $F_{\mathbf{Mon}}X$ has only finitely-many non-repeating words. Therefore, it has one or more non-repeating words of maximum length.
Question. Suppose $X$ is a finite set, $n$ is a natural number, and $|X|=n.$ In terms of $n$, what is the maximum length of a non-repeating word in $F_{\mathbf{Mon}}X$?
More briefly: what is the maximum length of a non-repeating word on $n$ letters?