import sys
input = sys.stdin.readline
def main():
  n=int(input())
  s=str(input())
  r=[]
  g=[]
  b=[]
  for i in range(n):
    if s[i]=='R':
      r.append(i)
    elif s[i]=='G':
      g.append(i)
    else:
      b.append(i)
  ans=0
  for l in r:
    for m in g:
      for k in b:
        if abs(m-l)!=abs(k-m) and abs(k-l)!=abs(k-m) and abs(k-l)!=abs(l-m):
          ans+=1
  print(ans)
main()