# 初期入力

N= int(eval(input()))

S =eval(input())





#

R_index=[]

G_index=[]

B_index=[]

for i,v in enumerate(S):

    if v =="R":

        R_index.append(i)

    if v =="G":

        G_index.append(i)

    if v =="B":

        B_index.append(i)



# 例　R_index各要素から等距離離れたところに左にG、右にBがあればOK

R_B =[]

B_G =[]

count_ij_jk_onaji =0

for r in R_index:

    for g in G_index:

        if 0<=g-(r-g) and g-(r-g)<N  :

            #if S[g-(r-g)]=="B" and r<g:

            if S[g-(r-g)]=="B" :

                count_ij_jk_onaji +=1

               # print(r,g,g-(r-g),"B")

for b in B_index:

    for r in R_index:

        if 0<=r-(b-r) and r-(b-r)<N :

            #if S[r-(b-r)] == "G" and b<r:

            if S[r-(b-r)] == "G" :

                count_ij_jk_onaji +=1

                #print(r,b,r-(b-r),"G")

for g in G_index:

    for b in B_index:

        if 0<=b-(g-b) and b-(g-b)<N :

            #if S[b-(g-b)] =="R" and g<b:

            if S[b-(g-b)] =="R":

                count_ij_jk_onaji +=1

                #print(b,g,b-(g-b),"R")



            

#3つとも異なる文字=all

kotae_all = len(R_index) * len(G_index) * len(B_index) 

print((kotae_all -count_ij_jk_onaji))
# 初期入力

N= int(eval(input()))

S =input().strip()



# RGBの各index

R =set([i for i, x in enumerate(S) if x == 'R'])

G =set([i for i, x in enumerate(S) if x == 'G'])

B =set([i for i, x in enumerate(S) if x == 'B'])





count =0

rgb =[]

for i in R:

    for j in G:

        k1 =j +(j -i)

        if k1 in B: #inはlistよりsetのほうが速い

            count +=1



for i in B:

    for j in R:

        k1 =j +(j -i)

        if k1 in G: #inはlistよりsetのほうが速い

            count +=1



for i in G:

    for j in B:

        k1 =j +(j -i)

        if k1 in R: #inはlistよりsetのほうが速い

            count +=1



all =len(R) *len(G) *len(B)

print((all -count))
# 初期入力
N = int(eval(input()))
S = eval(input())
#
R_index = []
G_index = []
B_index = []
for i, v in enumerate(S):
    if v == "R":
        R_index.append(i)
    if v == "G":
        G_index.append(i)
    if v == "B":
        B_index.append(i)
# 例　R_index各要素から等距離離れたところに左にG、右にBがあればOK
R_B = []
B_G = []
count_ij_jk_onaji = 0
for r in R_index:
    for g in G_index:
        if 0 <= g - (r - g) and g - (r - g) < N:
            # if S[g-(r-g)]=="B" and r<g:
            if S[g - (r - g)] == "B":
                count_ij_jk_onaji += 1
            # print(r,g,g-(r-g),"B")
for b in B_index:
    for r in R_index:
        if 0 <= r - (b - r) and r - (b - r) < N:
            # if S[r-(b-r)] == "G" and b<r:
            if S[r - (b - r)] == "G":
                count_ij_jk_onaji += 1
                # print(r,b,r-(b-r),"G")
for g in G_index:
    for b in B_index:
        if 0 <= b - (g - b) and b - (g - b) < N:
            # if S[b-(g-b)] =="R" and g<b:
            if S[b - (g - b)] == "R":
                count_ij_jk_onaji += 1
                # print(b,g,b-(g-b),"R")
# 3つとも異なる文字=all
kotae_all = len(R_index) * len(G_index) * len(B_index)
print((kotae_all - count_ij_jk_onaji))

# 初期入力
N = int(eval(input()))
S = input().strip()
# RGBの各index
R = set([i for i, x in enumerate(S) if x == "R"])
G = set([i for i, x in enumerate(S) if x == "G"])
B = set([i for i, x in enumerate(S) if x == "B"])
count = 0
rgb = []
for i in R:
    for j in G:
        k1 = j + (j - i)
        if k1 in B:  # inはlistよりsetのほうが速い
            count += 1
for i in B:
    for j in R:
        k1 = j + (j - i)
        if k1 in G:  # inはlistよりsetのほうが速い
            count += 1
for i in G:
    for j in B:
        k1 = j + (j - i)
        if k1 in R:  # inはlistよりsetのほうが速い
            count += 1
all = len(R) * len(G) * len(B)
print((all - count))

-S = eval(input()) -# -R_index = [] -G_index = [] -B_index = [] -for i, v in enumerate(S): -    if v == "R": -        R_index.append(i) -    if v == "G": -        G_index.append(i) -    if v == "B": -        B_index.append(i) -# 例　R_index各要素から等距離離れたところに左にG、右にBがあればOK -R_B = [] -B_G = [] -count_ij_jk_onaji = 0 -for r in R_index: -    for g in G_index: -        if 0 <= g - (r - g) and g - (r - g) < N: -            # if S[g-(r-g)]=="B" and r<g: -            if S[g - (r - g)] == "B": -                count_ij_jk_onaji += 1 -            # print(r,g,g-(r-g),"B") -for b in B_index: -    for r in R_index: -        if 0 <= r - (b - r) and r - (b - r) < N: -            # if S[r-(b-r)] == "G" and b<r: -            if S[r - (b - r)] == "G": -                count_ij_jk_onaji += 1 -                # print(r,b,r-(b-r),"G") -for g in G_index: -    for b in B_index: -        if 0 <= b - (g - b) and b - (g - b) < N: -            # if S[b-(g-b)] =="R" and g<b: -            if S[b - (g - b)] == "R": -                count_ij_jk_onaji += 1 -                # print(b,g,b-(g-b),"R") -# 3つとも異なる文字=all -kotae_all = len(R_index) * len(G_index) * len(B_index) -print((kotae_all - count_ij_jk_onaji)) +S = input().strip() +# RGBの各index +R = set([i for i, x in enumerate(S) if x == "R"]) +G = set([i for i, x in enumerate(S) if x == "G"]) +B = set([i for i, x in enumerate(S) if x == "B"]) +count = 0 +rgb = [] +for i in R: +    for j in G: +        k1 = j + (j - i) +        if k1 in B:  # inはlistよりsetのほうが速い +            count += 1 +for i in B: +    for j in R: +        k1 = j + (j - i) +        if k1 in G:  # inはlistよりsetのほうが速い +            count += 1 +for i in G: +    for j in B: +        k1 = j + (j - i) +        if k1 in R:  # inはlistよりsetのほうが速い +            count += 1 +all = len(R) * len(G) * len(B) +print((all - count))