f :: String -> String -> Bool
f s (x:y:[z]) = let
    a = dropCut (/=x) s
    b = dropCut (/=y) a
    c = dropWhile (/=z) b
    in c /= []
    where
        dropCut cond xs = let
            remains = dropWhile cond xs
            in if remains == [] then [] else tail remains

main = do
    let candidates = (\a b c -> [a, b, c]) <$> ['0'..'9'] <*> ['0'..'9'] <*> ['0'..'9']
    _ <- getLine
    s <- getLine

    print $ length $ filter (f s) candidates
