import Control.Monad
main = do
    getLine
    s <- getLine
    print $ length [()| pin <- replicateM 3 "0123456789", check pin s]

check (a:b:c:_) s = (c `elem`) . chk b $ chk a s
    where chk k t = case dropWhile (/= k) t of
                        [] -> []
                        (x:xs) -> xs