f :: (Int, Int) -> Char -> (Int, Int) f (v,a) 'D' = (if a == 0 then v + 1 else v, a - 1) f (v,a) 'U' = (v, a + 1) f x _ = x main :: IO () main = do count <- getLine steps <- getLine print $ fst $ foldl f (0,0) steps