n = gets.to_i
s = gets.strip

count = 0
('000'..'999').each do |pass|
  if first = s.index(pass[0])
    if second = s.index(pass[1], first+1)
       count += 1 if s.index(pass[2], second+1)
    end
  end
end
puts count
