a=int(eval(input()))

moji=eval(input())

r=set()

g=set()

b=set()

for i in range(a):

    if moji[i]=="R":

        r.add(i)

    elif moji[i]=="G":

        g.add(i)

    else:

        b.add(i)

res=len(r)*len(g)*len(b)

if len(r)==0 or len(g)==0 or len(b)==0:

    print((0))

else:

    min_len={0:r,1:g,2:b}

    a1=[]

    for i in range(3):

        a1.append(min_len[i])

    for i in a1[0]:

      for j in a1[1]:

        if -abs(i-j)+min(i,j) in a1[2]:

          res-=1

        if abs(i-j)+max(i,j) in a1[2]:

          res-=1

        if abs(i-j)%2==0 and  int(abs(i-j)/2)+min(i,j) in a1[2]:

          res-=1

    print(res)

                

    

a=int(eval(input()))

moji=eval(input())

r=[]

g=[]

b=[]

for i in range(a):

    if moji[i]=="R":

        r.append(i)

    elif moji[i]=="G":

        g.append(i)

    else:

        b.append(i)

res=len(r)*len(g)*len(b)

if len(r)==0 or len(g)==0 or len(b)==0:

    print((0))

else:

    min_len={0:r,1:g,2:b}

    if len(min_len[0])>len(min_len[1]):

        tmp=min_len[0]

        min_len[0]=min_len[1]

        min_len[1]=tmp

    if len(min_len[1])>len(min_len[2]):

        tmp=min_len[1]

        min_len[1]=min_len[2]

        min_len[2]=tmp

    if len(min_len[0])>len(min_len[1]):

        tmp=min_len[0]

        min_len[0]=min_len[1]

        min_len[1]=tmp

    a1=[]

    for i in range(3):

        a1.append(min_len[i])

    A=set(a1[0])

    B=set(a1[1])

    C=set(a1[2])

    for i in A:

        for j in B:

            if -abs(i-j)+min(i,j) in C:

                res-=1

            if abs(i-j)+max(i,j) in C:

                res-=1

            if abs(i-j)%2==0 and  int(abs(i-j)/2)+min(i,j) in C:

                res-=1

    print(res)

a = int(eval(input()))
moji = eval(input())
r = set()
g = set()
b = set()
for i in range(a):
    if moji[i] == "R":
        r.add(i)
    elif moji[i] == "G":
        g.add(i)
    else:
        b.add(i)
res = len(r) * len(g) * len(b)
if len(r) == 0 or len(g) == 0 or len(b) == 0:
    print((0))
else:
    min_len = {0: r, 1: g, 2: b}
    a1 = []
    for i in range(3):
        a1.append(min_len[i])
    for i in a1[0]:
        for j in a1[1]:
            if -abs(i - j) + min(i, j) in a1[2]:
                res -= 1
            if abs(i - j) + max(i, j) in a1[2]:
                res -= 1
            if abs(i - j) % 2 == 0 and int(abs(i - j) / 2) + min(i, j) in a1[2]:
                res -= 1
    print(res)

a = int(eval(input()))
moji = eval(input())
r = []
g = []
b = []
for i in range(a):
    if moji[i] == "R":
        r.append(i)
    elif moji[i] == "G":
        g.append(i)
    else:
        b.append(i)
res = len(r) * len(g) * len(b)
if len(r) == 0 or len(g) == 0 or len(b) == 0:
    print((0))
else:
    min_len = {0: r, 1: g, 2: b}
    if len(min_len[0]) > len(min_len[1]):
        tmp = min_len[0]
        min_len[0] = min_len[1]
        min_len[1] = tmp
    if len(min_len[1]) > len(min_len[2]):
        tmp = min_len[1]
        min_len[1] = min_len[2]
        min_len[2] = tmp
    if len(min_len[0]) > len(min_len[1]):
        tmp = min_len[0]
        min_len[0] = min_len[1]
        min_len[1] = tmp
    a1 = []
    for i in range(3):
        a1.append(min_len[i])
    A = set(a1[0])
    B = set(a1[1])
    C = set(a1[2])
    for i in A:
        for j in B:
            if -abs(i - j) + min(i, j) in C:
                res -= 1
            if abs(i - j) + max(i, j) in C:
                res -= 1
            if abs(i - j) % 2 == 0 and int(abs(i - j) / 2) + min(i, j) in C:
                res -= 1
    print(res)

-r = set() -g = set() -b = set() +r = [] +g = [] +b = [] -        r.add(i) +        r.append(i) -        g.add(i) +        g.append(i) -        b.add(i) +        b.append(i) +    if len(min_len[0]) > len(min_len[1]): +        tmp = min_len[0] +        min_len[0] = min_len[1] +        min_len[1] = tmp +    if len(min_len[1]) > len(min_len[2]): +        tmp = min_len[1] +        min_len[1] = min_len[2] +        min_len[2] = tmp +    if len(min_len[0]) > len(min_len[1]): +        tmp = min_len[0] +        min_len[0] = min_len[1] +        min_len[1] = tmp -    for i in a1[0]: -        for j in a1[1]: -            if -abs(i - j) + min(i, j) in a1[2]: +    A = set(a1[0]) +    B = set(a1[1]) +    C = set(a1[2]) +    for i in A: +        for j in B: +            if -abs(i - j) + min(i, j) in C: -            if abs(i - j) + max(i, j) in a1[2]: +            if abs(i - j) + max(i, j) in C: -            if abs(i - j) % 2 == 0 and int(abs(i - j) / 2) + min(i, j) in a1[2]: +            if abs(i - j) % 2 == 0 and int(abs(i - j) / 2) + min(i, j) in C: