from itertools import product



x1 = int(eval(input()))

x2 = eval(input())



R_i = [i for i, x in enumerate(x2) if x == "R"]

G_i = [i for i, x in enumerate(x2) if x == "G"]

B_i = {i for i, x in enumerate(x2) if x == "B"}



R = len(R_i)

G = len(G_i)

B = len(B_i)



xs = list(map(sorted, product(R_i, G_i)))



s = 0

for a in xs:

    k = a[1]*2 - a[0]  # 2j-i

    if k in B_i:

        s +=1

    i = a[0]*2 - a[1]  # 2j-k

    if i in B_i:

        s +=1

    j = (a[0] + a[1]) / 2

    if j.is_integer():

        j = int(j)

        if j in B_i:

            s +=1

print((R*G*B - s))
from itertools import product



x1 = int(eval(input()))

x2 = eval(input())



R_i = [i for i, x in enumerate(x2) if x == "R"]

G_i = [i for i, x in enumerate(x2) if x == "G"]

B_i = {i for i, x in enumerate(x2) if x == "B"}



R = len(R_i)

G = len(G_i)

B = len(B_i)



xs = list(map(sorted, product(R_i, G_i)))



s = 0

for a in xs:

    k = a[1]*2 - a[0]  # 2j-i

    if k in B_i:

        s +=1

    i = a[0]*2 - a[1]  # 2j-k

    if i in B_i:

        s +=1

    j = (a[0] + a[1]) / 2  # (i+k)/2

    if j in B_i:

        s +=1

print((R*G*B - s))
from itertools import product

x1 = int(eval(input()))
x2 = eval(input())
R_i = [i for i, x in enumerate(x2) if x == "R"]
G_i = [i for i, x in enumerate(x2) if x == "G"]
B_i = {i for i, x in enumerate(x2) if x == "B"}
R = len(R_i)
G = len(G_i)
B = len(B_i)
xs = list(map(sorted, product(R_i, G_i)))
s = 0
for a in xs:
    k = a[1] * 2 - a[0]  # 2j-i
    if k in B_i:
        s += 1
    i = a[0] * 2 - a[1]  # 2j-k
    if i in B_i:
        s += 1
    j = (a[0] + a[1]) / 2
    if j.is_integer():
        j = int(j)
        if j in B_i:
            s += 1
print((R * G * B - s))

from itertools import product

x1 = int(eval(input()))
x2 = eval(input())
R_i = [i for i, x in enumerate(x2) if x == "R"]
G_i = [i for i, x in enumerate(x2) if x == "G"]
B_i = {i for i, x in enumerate(x2) if x == "B"}
R = len(R_i)
G = len(G_i)
B = len(B_i)
xs = list(map(sorted, product(R_i, G_i)))
s = 0
for a in xs:
    k = a[1] * 2 - a[0]  # 2j-i
    if k in B_i:
        s += 1
    i = a[0] * 2 - a[1]  # 2j-k
    if i in B_i:
        s += 1
    j = (a[0] + a[1]) / 2  # (i+k)/2
    if j in B_i:
        s += 1
print((R * G * B - s))

-    j = (a[0] + a[1]) / 2 -    if j.is_integer(): -        j = int(j) -        if j in B_i: -            s += 1 +    j = (a[0] + a[1]) / 2  # (i+k)/2 +    if j in B_i: +        s += 1