import Data.List

main = do
    (n:ps) <- map read . words <$> getContents :: IO [Int]
    print $ n - (solve ps)

solve ps = succ . maximum . (0 :) . map length . filter (\g -> head g == LT ) . group $ zipWith compare is (tail is)
    where is = map snd . sort $ zip ps [1..]