use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}


fn main () {
    let N: u32 = read();
    let S: String = read();
    let chars: Vec<_> = S.chars().collect();
    let mut ans = 0;
    for i in 0..N {
        for j in 0.. N {
            for k in 0..N {
                if k > j && j > i {
                    if chars[i as usize] !=chars[j as usize] && chars[i as usize] != chars[k as usize] && chars[j as usize] != chars[k as usize] {
                        if j - i != k - j {
                            ans += 1;
                        }
                    }
                }
            }
        }
    }
    println!("{}", ans);
}