text made of English letters in both cases.
Call a letter *tidy* if it appears in text both in lowercase and in uppercase, and **every** lowercase occurrence comes before the **first** uppercase one.
Return the number of tidy letters.text="xyXzYZ" → 3
For each of x, y and z every lowercase copy comes before the first capital, so the answer is 3.
text="mMmN" → 0
For m a lowercase copy appears again after the capital M, and n has no lowercase copy at all. The answer is 0.
text="ppqPQq" → 1
text consists only of lowercase and uppercase English letterstext="xyXzYZ"
3
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.