#include <iostream>
#include <vector>

int main()
{
    long long N;
    std::cin >> N;
    long long n_r = 0, n_g = 0, n_b = 0;
    std::vector<char> S(N);
    for (long long i = 0; i < N; i++)
    {
        char c;
        std::cin >> c;
        S[i] = c;
        if (c == 'R')
        {
            n_r++;
        }
        else if (c == 'G')
        {
            n_g++;
        }
        else if (c == 'B')
        {
            n_b++;
        }
        else
        {
            return -1;
        }
    }

    long long count = 0;
    for (long long j = 1; j < N - 1; j++)
    {
        for (long long diff = 1; j - diff >= 0 && j + diff < N; diff++)
        {
            long long i = j - diff;
            long long k = j + diff;
            if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i])
            {
                count++;
            }
        }
    }
    std::cout << n_r * n_g * n_b - count << std::endl;
}
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT cin.tie(0); ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N, R;
    cin >> N >> R;

    cout << max(0LL, 10LL - N) * 100 + R << endl;

    return 0;
}