import java.util.Scanner;
public class Main{
static int N = 1000010;
static int cnt[] = new int[N];
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int res = 0;
for(int i = 1; i <= n*2 ; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
for(int j = a; j < b ; j ++) {
cnt[j]++;
if(cnt[j]==2) res++;
}
}
System.out.println(res);
}
}
网友评论