#include <cstdio>
#include <fstream>
#include <iostream>

#include <string>

using namespace std;

const int MAXN = 2e6 + 1;

int i, j, si, k;
char type;
string s;
long long ans = 0;
char c[MAXN];
int len[MAXN];


int main()
{
	ifstream cin("theblackpearl.in");
	ofstream cout("theblackpearl.out");
	getline(cin, s);
	ans = 0;
	int si = s.length();
	c[0] = s[i], len[0] = 1;
	for (i = 1; i < si; i++)
		if (c[k] == s[i]) ++len[k];
		else c[++k] = s[i], len[k] = 1;
	si = k + 1;		
	for (i = 0; i < si; ++i)
	{
		ans += len[i] * (len[i] + 1) / 2; 
		j = i + 1, type = c[i];
		while (j < si)
		{
			if (c[j] != '?')
			{
				if (type == '?' || type == c[j]) type = c[j];
				else break;
			}
		    ans += len[i] * len[j], ++j;      
		} 	
	}
	cout << ans << "\n";
}
