#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> N;
	string s;
	cin >> s;
	vector<int> char_pos[3];
	rep(i, N) {
		if (s[i] == 'R') char_pos[0].push_back(i + 1);
		if (s[i] == 'G') char_pos[1].push_back(i + 1);
		if (s[i] == 'B') char_pos[2].push_back(i + 1);
	}
	int _count = 0;
	rep(i, char_pos[0].size()) {
		rep(j, char_pos[1].size()) {
			rep(k, char_pos[2].size()) {
				int arr[3];
				arr[0] = char_pos[0][i];
				arr[1] = char_pos[1][j];
				arr[2] = char_pos[2][k];
				sort(arr, arr + 3);
				if (arr[2] - arr[1] == arr[1] - arr[0]) continue;
				else _count++;
			}
		}
	}
	cout << _count;
}
