n = int(eval(input()))

s = list(eval(input()))

cnt = 0

for i in range(1,n-1):

    if s[i] == 'R':

        cnt += (s[:i].count('G'))*(s[i+1:].count('B')) + (s[:i].count('B'))*(s[i+1:].count('G'))

    if s[i] == 'G':

        cnt += (s[:i].count('R'))*(s[i+1:].count('B')) + (s[:i].count('B'))*(s[i+1:].count('R'))

    if s[i] == 'B':

        cnt += (s[:i].count('G'))*(s[i+1:].count('R')) + (s[:i].count('R'))*(s[i+1:].count('G'))

for i in range(1,n-1):

    if s[i] == 'R':

        for j in range(1,min(i,n-i-1)+1):

            if s[i-j] == 'G' and s[i+j]=='B':

                cnt -=1

            if s[i-j] == 'B' and s[i+j]=='G':

                cnt -=1

    if s[i] == 'G':

        for j in range(1,min(i,n-i-1)+1):

            if s[i-j] == 'R' and s[i+j]=='B':

                cnt -=1

            if s[i-j] == 'B' and s[i+j]=='R':

                cnt -=1

    if s[i] == 'B':

        for j in range(1,min(i,n-i-1)+1):

            if s[i-j] == 'G' and s[i+j]=='R':

                cnt -=1

            if s[i-j] == 'R' and s[i+j]=='G':

                cnt -=1

print(cnt)
n = int(eval(input()))

s = list(eval(input()))

cnt = 0

cnt += s.count('R')*s.count('G')*s.count('B')

for i in range(1,n-1):

    if s[i] == 'R':

        for j in range(1,min(i,n-i-1)+1):

            if s[i-j] == 'G' and s[i+j]=='B':

                cnt -=1

            if s[i-j] == 'B' and s[i+j]=='G':

                cnt -=1

    if s[i] == 'G':

        for j in range(1,min(i,n-i-1)+1):

            if s[i-j] == 'R' and s[i+j]=='B':

                cnt -=1

            if s[i-j] == 'B' and s[i+j]=='R':

                cnt -=1

    if s[i] == 'B':

        for j in range(1,min(i,n-i-1)+1):

            if s[i-j] == 'G' and s[i+j]=='R':

                cnt -=1

            if s[i-j] == 'R' and s[i+j]=='G':

                cnt -=1

print(cnt)
n = int(eval(input()))
s = list(eval(input()))
cnt = 0
for i in range(1, n - 1):
    if s[i] == "R":
        cnt += (s[:i].count("G")) * (s[i + 1 :].count("B")) + (s[:i].count("B")) * (
            s[i + 1 :].count("G")
        )
    if s[i] == "G":
        cnt += (s[:i].count("R")) * (s[i + 1 :].count("B")) + (s[:i].count("B")) * (
            s[i + 1 :].count("R")
        )
    if s[i] == "B":
        cnt += (s[:i].count("G")) * (s[i + 1 :].count("R")) + (s[:i].count("R")) * (
            s[i + 1 :].count("G")
        )
for i in range(1, n - 1):
    if s[i] == "R":
        for j in range(1, min(i, n - i - 1) + 1):
            if s[i - j] == "G" and s[i + j] == "B":
                cnt -= 1
            if s[i - j] == "B" and s[i + j] == "G":
                cnt -= 1
    if s[i] == "G":
        for j in range(1, min(i, n - i - 1) + 1):
            if s[i - j] == "R" and s[i + j] == "B":
                cnt -= 1
            if s[i - j] == "B" and s[i + j] == "R":
                cnt -= 1
    if s[i] == "B":
        for j in range(1, min(i, n - i - 1) + 1):
            if s[i - j] == "G" and s[i + j] == "R":
                cnt -= 1
            if s[i - j] == "R" and s[i + j] == "G":
                cnt -= 1
print(cnt)

n = int(eval(input()))
s = list(eval(input()))
cnt = 0
cnt += s.count("R") * s.count("G") * s.count("B")
for i in range(1, n - 1):
    if s[i] == "R":
        for j in range(1, min(i, n - i - 1) + 1):
            if s[i - j] == "G" and s[i + j] == "B":
                cnt -= 1
            if s[i - j] == "B" and s[i + j] == "G":
                cnt -= 1
    if s[i] == "G":
        for j in range(1, min(i, n - i - 1) + 1):
            if s[i - j] == "R" and s[i + j] == "B":
                cnt -= 1
            if s[i - j] == "B" and s[i + j] == "R":
                cnt -= 1
    if s[i] == "B":
        for j in range(1, min(i, n - i - 1) + 1):
            if s[i - j] == "G" and s[i + j] == "R":
                cnt -= 1
            if s[i - j] == "R" and s[i + j] == "G":
                cnt -= 1
print(cnt)

-for i in range(1, n - 1): -    if s[i] == "R": -        cnt += (s[:i].count("G")) * (s[i + 1 :].count("B")) + (s[:i].count("B")) * ( -            s[i + 1 :].count("G") -        ) -    if s[i] == "G": -        cnt += (s[:i].count("R")) * (s[i + 1 :].count("B")) + (s[:i].count("B")) * ( -            s[i + 1 :].count("R") -        ) -    if s[i] == "B": -        cnt += (s[:i].count("G")) * (s[i + 1 :].count("R")) + (s[:i].count("R")) * ( -            s[i + 1 :].count("G") -        ) +cnt += s.count("R") * s.count("G") * s.count("B")