cswork / OAOpen practice workspace

ZipRecruiterOA #14

Triplets With Unique Chars

EasyJudge-ready

Topics (AI-labelled)Two PointersStrings

Given a string s containing only lowercase English letters, count the consecutive triplets in s made of pairwise distinct characters. In other words, count the indices i for which s[i], s[i+1], s[i+2] are pairwise different.

Input

One line with the string s. 1≤length of s≤1000, containing only lowercase English letters.

Output

Output one integer.

Example 1

Input:

abcdaaae

Output:

3

Example 2

Input:

abacaba

Output:

2

Example 3

Input:

xyz

Output:

1

Example notes

Example 1: s="abcdaaae"; i=0 (abc), i=1 (bcd), and i=2 (cda) qualify; in i=3 (daa), s[4] and s[5] are the same, and all later triplets also contain repeated characters, so the answer is 3. Example 2: s="abacaba"; only i=1 (bac) and i=3 (cab) qualify, and every other triplet contains two a's, so the answer is 2. Example 3: s="xyz" has only one triplet, which qualifies, so the answer is 1.

Editorial

Loading solution…