Submit solution

Points:
10 (partial)

Time limit:
1.0s

Memory limit:
256M

Authors:

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

A certain weeb wants to watch anime. However, he has commitments over the next hours, during which he cannot watch anime. To make matters worse, he is using a low quality streaming site that is only available for periods of time. Given his schedule over the next hours, figure out the total amount of time he can watch anime for.

#### Input Specification

The first line will contain 3 integers , , .

The next lines consist of 2 integers, , indicating that anime is streaming from hour to , inclusive.

The next lines consist of 2 integers, , indicating that the weeb in question cannot watch anime from hour to , inclusive.

For of points,

#### Output Specification

The total amount of anime this weeb can watch, in hours.

#### Sample Input 1

```
20 3 2
1 3
2 4
3 10
1 4
10 20
```

#### Sample Output 1

`5`

#### Explanation for Sample Output 1

The weeb can watch anime from hour 5 to hour 9.

#### Sample Input 2

```
20 3 2
1 20
3 5
6 8
1 10
1 20
```

#### Sample Output 2

`0`

## Comments

Can any of the A time periods overlap?

Yes.

Yes. C time periods may overlap as well. In retrospect, it makes no sense to have overlapping commitments.

He's just a really hard worker