1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int main()
{
	int a[256];
	for (int i = 0; i < 256; ++i)
		a[i] = 0;
	a[(int)'a'] = 2;
	a[(int)'b'] = 1;
	a[(int)'c'] = 1;
	a[(int)'d'] = 1;
	a[(int)'e'] = 2;
	a[(int)'f'] = 1;
	a[(int)'g'] = 1;
	a[(int)'h'] = 1;
	a[(int)'i'] = 2;
	a[(int)'j'] = 1;
	a[(int)'k'] = 1;
	a[(int)'l'] = 1;
	a[(int)'m'] = 1;
	a[(int)'n'] = 1;
	a[(int)'o'] = 2;
	a[(int)'p'] = 1;
	a[(int)'q'] = 1;
	a[(int)'r'] = 1;
	a[(int)'s'] = 1;
	a[(int)'t'] = 1;
	a[(int)'u'] = 2;
	a[(int)'v'] = 1;
	a[(int)'w'] = 1;
	a[(int)'x'] = 1;
	a[(int)'y'] = 2;
	a[(int)'z'] = 1;

	int ch;
	long long result = 0;
	int triIdx = 0;
	int idx = 0;
	int lastCh = 0;
	int triCount = 0;
	while ((ch = getchar()) != EOF)
	{
		ch = a[ch];
		if (ch == 0)
			break;

		if (ch == lastCh)
		{
			++triCount;
			if (triCount >= 2)
				triIdx = idx - 1;
		}
		else
		{
			triCount = 0;
		}

		result += triIdx;

		lastCh = ch;
		++idx;
	}

	printf("%lld", result);
	return 0;
}