/*
TASK:round
LANG:C++
*/
#include <stdio.h>
#include <string.h>

char table[4000];
short n, v1c, v2c, v1[2000], v2[2000];

short min(short a, short b)
{
  if(a < b)
    return a;
  return b;
}

short minsu1(short pos)
{
  short res1, res2, c;
  for(res1 = 0, c = 1; c != pos; res1 += table[(c++)-1]);
  for(res2 = 0, c = 2*n; c != pos; res2 += table[(c--)-1]);
  return min(res1, res2);
}

short minsu2(short pos)
{
  short res1, res2, c;
  for(res1 = 0, c = n+1; c != pos; res1 += table[c-1])
  {
    c++;
    if(c > 2*n)
      c = 1;
  }
  for(res2 = 0, c = 2*n; c != pos; res2 += table[c-1])
  {
    c--;
    if(c < 1)
      c = 2*n;
  }
  return min(res1, res2);
}

short best(short v1c, short v2c)
{
  short res1, res2;
  if(v1c == n && v2c == n)
    return 0;
  if(v1c < n && v2c < n)
  {
    table[v1[v1c]] = 1;
    res1 = best(v1c+1, v2c)+minsu1(v1[v1c]);
    table[v1[v1c]] = 0;
    table[v2[v2c]] = 1;
    res2 = best(v1c, v2c+1)+minsu2(v2[v2c]);
    table[v2[v2c]] = 0;
    return min(res1, res2);
  }
  if(v1c < n)
  {
    table[v1[v1c]] = 1;
    res1 = best(v1c+1, v2c)+minsu1(v1[v1c]);
    table[v1[v1c]] = 0;
    return res1;
  }
  table[v2[v2c]] = 1;
  res2 = best(v1c, v2c+1)+minsu2(v2[v2c]);
  table[v2[v2c]] = 0;
  return res2;
}

int main(void)
{
  memset(table, 0, 4000);
  scanf("%hd", &n);
  for(v1c = 0; v1c < n; v1c++)
    scanf("%hd", &v1[v1c]);
  for(v2c = 0; v2c < n; v2c++)
    scanf("%hd", &v2[v2c]);
  printf("%hd\n", best(0, 0)); 
  return 0;
}
