def solution(n, lost, reserve):
clothes = []
for i in range(n):
clothes.append(1);
for i in lost:
clothes[i-1] -= 1;
for i in reserve:
clothes[i-1] += 1;
if clothes[0] == 2 and clothes[1] == 0:
clothes[0] -= 1;
clothes[1] += 1;
if clothes[1] == 2 and clothes[0] == 0:
clothes[1] -= 1;
clothes[0] += 1;
if clothes[n-1] == 2 and clothes[n-2] == 0:
clothes[n-1] -= 1;
clothes[n-2] += 1;
if clothes[n-2] == 2 and clothes[n-1] == 0:
clothes[n-2] -= 1;
clothes[n-1] += 1;
for i in range(2,n-1):
if clothes[i] == 2 and clothes[i+1] == 0:
clothes[i] -= 1;
clothes[i+1] += 1;
if clothes[i+1] == 2 and clothes[i] == 0:
clothes[i+1] -= 1;
clothes[i] += 1;
answer = 0;
for i in clothes:
if i == 1 or i == 2:
answer += 1;
return answer