n = int(eval(input()))

s = eval(input())

r, g, b = [], [], []

cnt = 1

for i in s:

    if i == 'R':

        r.append(cnt)

    elif i == 'G':

        g.append(cnt)

    else:

        b.append(cnt)

    cnt += 1

rd = set([x * 2 for x in r])

gd = set([x * 2 for x in g])

bd = set([x * 2 for x in b])

ddc = 0

for i in r:

    for j in g:

        if i + j in bd:

            ddc += 1

for j in g:

    for k in b:

        if j + k in rd:

            ddc += 1

for i in r:

    for k in b:

        if i + k in gd:

            ddc += 1

print((len(r) * len(g) * len(b) - ddc))
n = int(eval(input()))

s = eval(input())

r, g, b = [], [], []

cnt = 1

for i in s:

    if i == 'R':

        r.append(cnt)

    elif i == 'G':

        g.append(cnt)

    else:

        b.append(cnt)

    cnt += 1

rd = set([x * 2 for x in r]) #以下2つ目の条件を満たさないもの(j - i = k - j)の数え上げ

gd = set([x * 2 for x in g])

bd = set([x * 2 for x in b])

ddc = 0

for i in r:

    for j in g:

        if i + j in bd:

            ddc += 1

for j in g:

    for k in b:

        if j + k in rd:

            ddc += 1

for i in r:

    for k in b:

        if i + k in gd:

            ddc += 1

print((len(r) * len(g) * len(b) - ddc)) #1つ目の条件を満たすモノから2つ目の条件を満たさないものを引く
n = int(eval(input()))
s = eval(input())
r, g, b = [], [], []
cnt = 1
for i in s:
    if i == "R":
        r.append(cnt)
    elif i == "G":
        g.append(cnt)
    else:
        b.append(cnt)
    cnt += 1
rd = set([x * 2 for x in r])
gd = set([x * 2 for x in g])
bd = set([x * 2 for x in b])
ddc = 0
for i in r:
    for j in g:
        if i + j in bd:
            ddc += 1
for j in g:
    for k in b:
        if j + k in rd:
            ddc += 1
for i in r:
    for k in b:
        if i + k in gd:
            ddc += 1
print((len(r) * len(g) * len(b) - ddc))

n = int(eval(input()))
s = eval(input())
r, g, b = [], [], []
cnt = 1
for i in s:
    if i == "R":
        r.append(cnt)
    elif i == "G":
        g.append(cnt)
    else:
        b.append(cnt)
    cnt += 1
rd = set([x * 2 for x in r])  # 以下2つ目の条件を満たさないもの(j - i = k - j)の数え上げ
gd = set([x * 2 for x in g])
bd = set([x * 2 for x in b])
ddc = 0
for i in r:
    for j in g:
        if i + j in bd:
            ddc += 1
for j in g:
    for k in b:
        if j + k in rd:
            ddc += 1
for i in r:
    for k in b:
        if i + k in gd:
            ddc += 1
print((len(r) * len(g) * len(b) - ddc))  # 1つ目の条件を満たすモノから2つ目の条件を満たさないものを引く

-rd = set([x * 2 for x in r]) +rd = set([x * 2 for x in r])  # 以下2つ目の条件を満たさないもの(j - i = k - j)の数え上げ -print((len(r) * len(g) * len(b) - ddc)) +print((len(r) * len(g) * len(b) - ddc))  # 1つ目の条件を満たすモノから2つ目の条件を満たさないものを引く