
rInt = read :: String -> Int

fn [] = 0
fn ((a,x):[]) = if a==x then 1 else 0
fn ((a,x):((b,y):r)) = if a/=x then fn ((b,y):r) else 1 + fn r


main = do
    n <- rInt <$> getLine
    p <- ((map rInt) . words) <$> getLine
    print $ fn $ zip p [1..n]
    