N = gets.to_i
S = gets.chomp

ans = 0
A = [*"0".."9"]
A.each do |x|
  next unless i = S.index(x)
  A.each do |y|
    if j = S.index(y, i+1)
      ans += A.count {|z| S.index(z, j+1) }
    end
  end
end
puts ans