#include <string>
#include <vector>
using namespace std;
int solution(int n, vector<int> lost, vector<int> reserve) {
vector<int> students(n+2);
fill(students.begin(), students.end(), 1);
students[0]=-1;
students[n+1]=-1;
for(int i=0; i<lost.size(); i++)
students[lost[i]] -=1;
for(int i=0; i<reserve.size(); i++)
students[reserve[i]] +=1;
for(int i=1; i<students.size(); i++)
{
if(students[i]==0)
{
if(students[i-1] ==2)
{
students[i]++;
students[i-1]--;
}
else if(students[i+1] ==2)
{
students[i]++;
students[i+1]--;
}
}
}
int answer = 0;
for(int i=1; i<students.size(); i++)
if(students[i]>=1)
answer++;
return answer;
}