  We introduce and study a new complexity function in combinatorics on words, which takes into account the smallest second occurrence time of a factor of an infinite word. We characterize the eventually periodic words and the Sturmian words by means of this function. Then, we establish a new result on repetitions in Sturmian words and show that it is best possible. Let $b \ge 2$ be an integer. We deduce a lower bound for the irrationality exponent of real numbers whose sequence of $b$-ary digits is a Sturmian sequence over $\{0,1,\ldots, b-1\}$ and we prove that this lower bound is best possible. As an application, we derive some information on the $b$-ary expansion of $\log(1+\frac{1}{a})$,for any integer $a \ge 34$. 
A new complexity function, repetitions in Sturmian words, and   irrationality exponents of Sturmian numbers