isIn :: String -> String -> Bool
isIn (x:y:[z]) = (/=[]) . dropWhile (/=z) . dropCut (/=y) . dropCut (/=x)

dropCut cond xs
    | null remains = []
    | otherwise    = tail remains
  where
    remains = dropWhile cond xs

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

    print $ length $ filter (`isIn` s) candidates
