An astronomy team keeps a single running logbook for a nocturnal beacon they are studying. Every time a duty observer spots the beacon, they append one character to the logbook: the matching uppercase letter if the sighting happened during a daytime shift, and the matching lowercase letter if it happened during a nighttime shift. A letter of the alphabet is considered fully confirmed if the beacon's signature for that letter was logged at least once during the day and at least once during the night.
Given the logbook string, determine how many distinct letters are fully confirmed.
A single line containing the logbook string s.
Print a single integer: the number of letters that appear in s in both lowercase and uppercase form.
1 <= s.length <= 50s consists only of uppercase and lowercase English letters (a-z, A-Z).Example 1
Input
aaAbcBc
Expected
2
Explanation
The string contains lowercase a, b, c and uppercase A, B. The letter a appears in lowercase (index 0) and uppercase (index 2), so it is confirmed. The letter b appears in lowercase (index 3) and uppercase (index 5), so it is confirmed too. The letter c only ever appears in lowercase, never uppercase, so it does not count. That gives 2 confirmed letters.
Example 2
Input
qwertyQWERTYuiopUIOP
Expected
10
Explanation
Each of the ten letters q, w, e, r, t, y, u, i, o, p appears once in lowercase in the first block of the string and once in uppercase in the second block, so all 10 distinct letters are confirmed.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →