n = gets.to_i
c = 0
s = gets
s.gsub!(/(\d)\1\1+/, '\1\1\1')
10.times {|l|
  10.times {|m|
    10.times {|r|
      next  unless i = s.index(l.to_s)
      next  unless i = s.index(m.to_s,i+1)
      next  unless s.index(r.to_s,i+1)
      c += 1
} } }
p c