nketa = STDIN.gets.chomp.to_i
lucky = STDIN.gets.chomp.split('')

array = [*0..1000].map do |x|
  if x >= 100
    x.to_s
  elsif x < 10
    "00#{x}"
  else
    "0#{x}"
  end
end

count = 0

def can_make?(target, lucky)
  flg1 = false
  flg2 = false
  flg3 = false
  lucky.each do |x|
    if !flg1 && target[0] == x
      flg1 = true
    elsif !flg2 && flg1 && target[1] == x
      flg2 = true
    elsif flg2 && target[2] == x
      flg3 = true
    end
  end
  flg1 && flg2 && flg3
end

array.each do |target|
  if can_make?(target, lucky)
    count += 1
  end
end
puts count

