Oscar is playing games throughout an entire course! In this course, there are friends, and
snitches. Each friend will cover Oscar for a consecutive number of lessons, from
to
, inclusive. Each snitch will be next to Oscar for a consecutive number of lessons, from
to
, inclusive. Oscar is only able to play games during lessons when there is at least one friend covering him, and when no snitches are next to him. At times where there are friends and snitches or no friends and no snitches next to him, Oscar cannot play games.
Given that there are lessons in this course numbered from
to
, can you determine how many lessons Oscar will play games for in total?
Input Specification
The first line will contain
,
, and
, the number of friends, snitches, and lessons in the course, respectively.
The next lines will contain integers
and
, the consecutive lessons where Oscar is covered for.
The next lines will contain integers
and
, the consecutive lessons where a snitch is near Oscar.
Output Specification
Output one integer, the total number of lessons that Oscar will play games for in total.
Sample Input 1
2 1 10
1 3
4 6
5 9
Sample Output 1
4
Sample Explanation
The first friend covers Oscar for the first lessons. The second friend covers him from lesson
to
, but there is a snitch that is near him from lesson
to
, so he can only play during lesson
. During lesson
, since there is no friend covering him, Oscar cannot play games either. Thus, the answer is
as Oscar will play games from lesson
to lesson
.
Comments