#include <bits/stdc++.h>
using namespace std;
const int max_n = 20;
const int inf = 0x3f3f3f3f;
int n, a[max_n], b[max_n];
int c[max_n];
int flip[max_n];
int p[max_n];
bool cmp(int x, int y) { return c[x] == c[y] ? x < y : c[x] < c[y]; }
int solve(int state) {
  for (int i = 0; i < n; i++) flip[i] = 0;
  int res = 0;
  for (int i = 0; i < n; i++) p[i] = i;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (c[i] < c[j]) {
        res++;
        flip[i] ^= 1, flip[j] ^= 1;
      }
    }
  }
  return res;
  sort(p, p + n, cmp);
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j < n && c[p[j]] == c[p[i]]) j++;
    for (int l = i; l < j; l++) {
      if (flip[p[l]] != (state >> p[l] & 1)) {
        if (l == j - 1) return inf;
        res++;
        flip[p[l]] ^= 1, flip[p[l + 1]] ^= 1;
      }
    }
    i = j - 1;
  }
  return res;
}
int tc[max_n];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) scanf("%d", b + i);
  int ans = inf;
  int state = 0;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if (i >> j & 1)
        c[j] = b[j];
      else
        c[j] = a[j];
    }
    ans = min(ans, solve(i));
  }
  return 0;
}
