/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming

Solution to https://open.kattis.com/problems/freefood
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    bool hasEvent[366];
    for(int i = 0; i < 366; i++)
        hasEvent[i] = false;
    
    for(int i = 0; i < n; i++) {
        int s, t;
        cin >> s >> t;
        for(int j = s; j <= t; j++) {
            hasEvent[j] = true;
        }
    }
    
    int res = 0;
    for(int i = 1; i <= 365; i++) {
        if(hasEvent[i]) {
            res++;
        }
    }
    cout << res << endl;
}