function Main(input) {
    const inputArr = input.split("\n");
    const tarStr = inputArr[1]
    const _tarS = new Array(Number(inputArr[0]))
    const tarS = _tarS.reduce((pre, cur, index)=>{
        return [...pre, index+1]
    },[])
    let num = 0;
    const check =(v1,v2,v3)=> {
        return v1 !== v2 && v2 !== v3 && v3 !== v1
    }
    tarS.forEach(first=>{
        tarS.forEach(second=>{
            tarS.forEach(third=>{
                if (check(tarStr.slice(first, first+1),tarStr.slice(second, second+1),tarStr.slice(third, third+1)) && first < second && second < third && (second - first !== third - second)) {
                    num ++;
                }
            })
        })
    })
    console.log(num)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
