MicrosoftOA #16
Count Characters Before Uppercase
估计简单可在线判题
Consider only the text strictly before the first uppercase English letter, and count the distinct lowercase English letters in it; if there is no uppercase letter, consider the whole text. Under this definition, the original site's example aaAbcCABBc should give 1; this site has corrected it.
输入格式
This site's input: one line of printable ASCII text of length 0..100000, which may contain spaces; only A..Z and a..z count as letters.
输出格式
Output a single integer, the answer.
样例 1
输入:
aaAbcCABBc
输出:
1
样例 2
输入:
abca
输出:
3
样例 3
输入:
XYZ
输出:
0
样例说明
Example 1: only aa comes before the first uppercase A, and its only distinct lowercase letter is a; the answer is 1.
Example 2: there is no uppercase letter, and the distinct lowercase letters in the whole text are a, b, c; the answer is 3.
Example 3: the first character is already uppercase, so the prefix is empty; the answer is 0.