n = gets.chomp.to_i
s = gets.chomp
count = 0
bangou = "024"
pos = 0
(0..999).each{|elem|
  bangou = format('%03d', elem)
s.chars{|str|
  if str == bangou[pos] and pos <= 3
    pos+=1
  else
  end 
  }
  count +=1 if pos ==3
  pos =0
  }

puts count
