n = gets.to_i
S = gets.chomp.chars
A = S.uniq
# p A
ans = 0
A.each do |i|
    i_b = S.index(i) + 1
    # p i_b
    b = S[i_b..-1]
    next if b.size == 0
    b = b.uniq
    b.each do |j|
        i_c = S[i_b..-1].index(j) + 1
        c = S[i_b..-1][i_c..-1]
        # p [b,c]
        if !!c 
            c = c.uniq
            ans += c.size
        end
    end
end

puts ans