N = int(eval(input()))

S = eval(input())

sum = 0

r = 0

g = 0

b = 0



for i in range(N):

    if S[i] == "R":

        r+=1

    elif S[i] == "G":

        g+=1

    else:

        b+=1



sum = r*g*b



for i in range(N):

    for j in range((N-i)//2 +1):

        try:

            a = S[i]

            b = S[i+j]

            c = S[i+2*j]

            if a!=b and b!=c and c!=a:

                sum -= 1

        except:

            continue



print(sum)
N = int(eval(input()))

S = eval(input())

sum = 0

r = 0

g = 0

b = 0



for i in range(N):

    if S[i] == "R":

        r+=1

    elif S[i] == "G":

        g+=1

    else:

        b+=1



sum = r*g*b



for i in range(N):

    for j in range(N):

        try:

            a = S[i]

            b = S[i+j]

            c = S[i+2*j]

            if a!=b and b!=c and c!=a:

                sum -= 1

        except:

            break



print(sum)

N = int(eval(input()))
S = eval(input())
sum = 0
r = 0
g = 0
b = 0
for i in range(N):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1
sum = r * g * b
for i in range(N):
    for j in range((N - i) // 2 + 1):
        try:
            a = S[i]
            b = S[i + j]
            c = S[i + 2 * j]
            if a != b and b != c and c != a:
                sum -= 1
        except:
            continue
print(sum)

N = int(eval(input()))
S = eval(input())
sum = 0
r = 0
g = 0
b = 0
for i in range(N):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1
sum = r * g * b
for i in range(N):
    for j in range(N):
        try:
            a = S[i]
            b = S[i + j]
            c = S[i + 2 * j]
            if a != b and b != c and c != a:
                sum -= 1
        except:
            break
print(sum)

-    for j in range((N - i) // 2 + 1): +    for j in range(N): -            continue +            break