import std.algorithm;
import std.string;
import std.stdio;

void main() {
	readln;
	string s = readln.chomp;

	if (s.length < 3) {
		writeln("0");
		return;
	}
	
	auto c = count(s, 'R') * count(s, 'G') * count(s, 'B');

	foreach (i;1..(s.length + 1) / 2) {
		for (size_t j = 0;j + i + i < s.length;++j) {
			if (cast(int)s[j] + s[j + i] + s[j + i + i] == 0x52 + 0x47 + 0x42) {
				--c;
			}
		}
	}

	writeln(c);
}
