n,s=open(0);n=int(n);c=s.count;print((c('R')*c('G')*c('B')-sum(len(set(s[i:j+1:j-i>>1]))>2for i in range(n)for j in range(i+2,n,2))))
n,s=open(0);n=int(n);c=s.count;print((c('R')*c('G')*c('B')-sum(s[i]!=s[j]!=s[i+j>>1]!=s[i]for i in range(n)for j in range(i+2,n,2))))
n, s = open(0)
n = int(n)
c = s.count
print(
    (
        c("R") * c("G") * c("B")
        - sum(
            len(set(s[i : j + 1 : j - i >> 1])) > 2
            for i in range(n)
            for j in range(i + 2, n, 2)
        )
    )
)

n, s = open(0)
n = int(n)
c = s.count
print(
    (
        c("R") * c("G") * c("B")
        - sum(
            s[i] != s[j] != s[i + j >> 1] != s[i]
            for i in range(n)
            for j in range(i + 2, n, 2)
        )
    )
)

-            len(set(s[i : j + 1 : j - i >> 1])) > 2 +            s[i] != s[j] != s[i + j >> 1] != s[i]