{-# OPTIONS_GHC -Wno-unused-imports #-} {-# OPTIONS_GHC -Wno-unused-top-binds #-} {-# OPTIONS_GHC -Wno-missing-signatures #-} import Control.Monad import Control.Monad.State.Strict import Control.Applicative import Data.Bool import Data.Function import Data.List import Data.Ord import Data.List.Split -- import System.IO (hFlush, stdout) import Debug.Trace input = getLine :: IO String ii = readLn :: IO Int li = map read . words <$> getLine :: IO [Int] printYn b = putStrLn $ bool "No" "Yes" b pairwise :: [a] -> [(a, a)] pairwise xs = zip xs (drop 1 xs) windows :: Int -> [a] -> [[a]] windows size xs | length w < size = [] | otherwise = w : windows size (drop 1 xs) where w = take size xs countIf f = length . filter f minmax (x:xs) = foldl' (\(mi, ma) x -> (min mi x, max ma x)) (x, x) xs solve ('H':'A':'P':'P':'Y':cs) = 1 + solve cs solve (_:cs) = solve cs solve [] = 0 main :: IO () main = do n <- ii s <- input let (a, b) = splitAt (n-5) s let ans = (solve a) + diff b "HAPPY" print ans where diff xs ys = countIf (\(x, y) -> x /= y) $ zip xs ys