N=io.read"*n"
io.read()
S=io.read()
local function count_char(s,c)
	local ret=0
	for _ in s:gmatch(c)do ret=ret+1 end
	return ret
end
c=count_char(S,"R")*count_char(S,"G")*count_char(S,"B")
for i=1,N do
	local I=S:sub(i,i)
	for d=1,(N-i)/2 do
		local J=S:sub(i+d,i+d)
		local K=S:sub(i+d+d,i+d+d)
		if(I~=J and J~=K and K~=I)then c=c-1 end
	end
end
print(c)