local n = io.read("*n")
local a = {}
for i = 1, n do
  local tmp = {i, io.read("*n")}
  a[i] = tmp
end
table.sort(a, function(x, y) return x[2] < y[2] end)
local cnt = 0
for i = 1, n do
  if (i + a[i][1]) % 2 == 1 then
    cnt = cnt + 1
  end
end
print(cnt / 2)
