n = gets.to_i s = gets.chomp.bytes cs = s.map.with_index { [_1, _2] }.group_by { _1[0] }.transform_values { _1.map { |a| a[1] } } ans = 0 cs.each do |c1, ids| next if ids == 1 ids.combination(2) do |i1, i3| ((i1 + 1)...i3).each do |i2| c2 = s[i2] next if c2 == c1 ((i3 + 1)...n).each do |i4| c4 = s[i4] next if c4 == c1 || c4 == c2 ((i4 + 1)...n).each do |i5| c5 = s[i5] next if c5 == c1 || c5 == c4 || c5 == c2 ans += 1 end end end end end puts ans