N=io.read("*n", "*l")
S=io.read()

counter = 0

for i=1,N do
    for j=1,N do
        if i<j then
            for k=1,N do
                if j<k and j-i~=k-j then
                    if S:sub(i,i)~=S:sub(j,j) and S:sub(i,i)~=S:sub(k,k) and S:sub(j,j)~=S:sub(k,k) then
                        counter = counter + 1
                    end
                end
            end
        end
    end
end

print(counter)