(require '[clojure.string :as str])

(defn luckyPin3 [n s]
  (->>
   (for [i (range 1000)
         :let [a (format "%03d" i)
               a0 (get a 0)
               a1 (get a 1)
               a2 (get a 2)]
         :when (some? 
                (some->>
                 (str/index-of s a0 0)
                 (inc)
                 (str/index-of s a2)
                 (inc)
                 (str/index-of s a1)))]
     a)
   (count)))

(println (luckyPin3 (read-line) (read-line)))