N = int(eval(input()))

S = list(eval(input()))

R = []

G = []

B = []

Reval = {}

Geval = {}

Beval = {}

for i in range(N):

    if S[i] == "R":

        R.append(i)

        Reval[2*i] = 2*i

    elif S[i] == "G":

        G.append(i)

        Geval[2*i] = 2*i

    elif S[i] == "B":

        B.append(i)

        Beval[2*i] = 2*i

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



for a in R:

    for b in G:

        if (a + b) in Beval:

            count -= 1

for a in G:

    for b in B:

        if (a + b) in Reval:

            count -= 1

for a in B:

    for b in R:

        if (a + b) in Geval:

            count -= 1

print(count)
def main():

    N = int(eval(input()))

    S = list(eval(input()))

    R = []

    G = []

    B = []

    Reval = {}

    Geval = {}

    Beval = {}

    for i in range(N):

        if S[i] == "R":

            R.append(i)

            Reval[2*i] = 2*i

        elif S[i] == "G":

            G.append(i)

            Geval[2*i] = 2*i

        elif S[i] == "B":

            B.append(i)

            Beval[2*i] = 2*i

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



    for a in R:

        for b in G:

            if (a + b) in Beval:

                count -= 1

    for a in G:

        for b in B:

            if (a + b) in Reval:

                count -= 1

    for a in B:

        for b in R:

            if (a + b) in Geval:

                count -= 1

    print(count)



if __name__ == "__main__":

    main()

N = int(eval(input()))
S = list(eval(input()))
R = []
G = []
B = []
Reval = {}
Geval = {}
Beval = {}
for i in range(N):
    if S[i] == "R":
        R.append(i)
        Reval[2 * i] = 2 * i
    elif S[i] == "G":
        G.append(i)
        Geval[2 * i] = 2 * i
    elif S[i] == "B":
        B.append(i)
        Beval[2 * i] = 2 * i
count = len(R) * len(G) * len(B)
for a in R:
    for b in G:
        if (a + b) in Beval:
            count -= 1
for a in G:
    for b in B:
        if (a + b) in Reval:
            count -= 1
for a in B:
    for b in R:
        if (a + b) in Geval:
            count -= 1
print(count)

def main():
    N = int(eval(input()))
    S = list(eval(input()))
    R = []
    G = []
    B = []
    Reval = {}
    Geval = {}
    Beval = {}
    for i in range(N):
        if S[i] == "R":
            R.append(i)
            Reval[2 * i] = 2 * i
        elif S[i] == "G":
            G.append(i)
            Geval[2 * i] = 2 * i
        elif S[i] == "B":
            B.append(i)
            Beval[2 * i] = 2 * i
    count = len(R) * len(G) * len(B)
    for a in R:
        for b in G:
            if (a + b) in Beval:
                count -= 1
    for a in G:
        for b in B:
            if (a + b) in Reval:
                count -= 1
    for a in B:
        for b in R:
            if (a + b) in Geval:
                count -= 1
    print(count)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -S = list(eval(input())) -R = [] -G = [] -B = [] -Reval = {} -Geval = {} -Beval = {} -for i in range(N): -    if S[i] == "R": -        R.append(i) -        Reval[2 * i] = 2 * i -    elif S[i] == "G": -        G.append(i) -        Geval[2 * i] = 2 * i -    elif S[i] == "B": -        B.append(i) -        Beval[2 * i] = 2 * i -count = len(R) * len(G) * len(B) -for a in R: -    for b in G: -        if (a + b) in Beval: -            count -= 1 -for a in G: -    for b in B: -        if (a + b) in Reval: -            count -= 1 -for a in B: -    for b in R: -        if (a + b) in Geval: -            count -= 1 -print(count) +def main(): +    N = int(eval(input())) +    S = list(eval(input())) +    R = [] +    G = [] +    B = [] +    Reval = {} +    Geval = {} +    Beval = {} +    for i in range(N): +        if S[i] == "R": +            R.append(i) +            Reval[2 * i] = 2 * i +        elif S[i] == "G": +            G.append(i) +            Geval[2 * i] = 2 * i +        elif S[i] == "B": +            B.append(i) +            Beval[2 * i] = 2 * i +    count = len(R) * len(G) * len(B) +    for a in R: +        for b in G: +            if (a + b) in Beval: +                count -= 1 +    for a in G: +        for b in B: +            if (a + b) in Reval: +                count -= 1 +    for a in B: +        for b in R: +            if (a + b) in Geval: +                count -= 1 +    print(count) + + +if __name__ == "__main__": +    main()