In this article, we show that the Kamae-Xue complexity function for an infinite sequence classifies eventual periodicity completely. We prove that an infinite binary word x(1)x(2)... is eventually periodic if and only if Sigma(x(1)x(2)...x(n))/n(3) has a positive limit, where Sigma(x(1)x(2)...x(n)) is the sum of the squares of all the numbers of occurrences of finite words in x(1)x(2)...x(n), which was introduced by Kamae-Xue as a criterion of randomness in the sense that x(1)x(2)...x(n) is more random if Sigma(x(1)x(2)...x(n)) is smaller. In fact, it is known that the lower limit of Sigma(x(1)x(2)...x(n))/n(2) is at least 3/2 for any sequence x(1)x(2)..., while the limit exists as 3/2 almost surely for the (1/2, 1/2) product measure. For the other extreme, the upper limit of Sigma(x(1)x(2)...x(n))/n(3) is bounded by 1/3. There are sequences which are not eventually periodic but the lower limit of Sigma(x(1)x(2)...x(n))/n(3) is positive, while the limit does not exist. (C) 2015 Elsevier B.V. All rights reserved.