import java.util.*;
import java.io.*;

public class theblackpearl_dk_slow {
	BufferedReader br;
	PrintWriter out;
	StringTokenizer stok;

	String nextToken() throws IOException {
		while (stok == null || !stok.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null) {
				return null;
			}
			stok = new StringTokenizer(s);
		}
		return stok.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	char nextChar() throws IOException {
		return (char) (br.read());
	}

	String nextLine() throws IOException {
		return br.readLine();
	}
	
	void solve() throws IOException {
		String s = nextLine();
		long ans = 0;
		for (int i = 0; i < s.length(); i++) {
			for (int j = i; j < s.length(); j++) {
				HashSet<Integer> set = new HashSet<Integer>();
				for (int k = i; k <= j; k++) {
					if (s.charAt(k) != '?') set.add((int) s.charAt(k));
				}
				if (set.size() <= 1) ans += 1;
			}
		}
		out.println(ans);
	}

	void run() throws IOException {
		 br = new BufferedReader(new FileReader("theblackpearl.in"));
		 out = new PrintWriter("theblackpearl.out");
		// br = new BufferedReader(new InputStreamReader(System.in));
		// out = new PrintWriter(System.out);
		solve();
		br.close();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		// Localea.setDefault(Locale.US);
		new theblackpearl_dk_slow().run();
	}
}