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

local S_byte = {S:byte(1, N)}
local count = 0
for i = 1, N - 2 do
    for j = i + 1, N - 1 do
        for k = j + 1, N do
            if j-i ~= k-j and S_byte[i] ~= S_byte[j] and S_byte[i] ~= S_byte[k] and S_byte[j] ~= S_byte[k] then
                count = count + 1
            end
        end
    end
end

print(count)