gets # drop n
s = gets.chomp

digit = (0..9).to_a.map(&:to_s)

puts (digit).product(digit, digit).count { |digits|
  last_index = -1
  digits.all? { |digit|
    last_index = s.index(digit, last_index + 1)
  }
}
