#include<iostream>
using namespace std;

const int N = 1e5 + 5;
struct node{
    int l, r;
}a[N];
int n, t, s;    

int main(){

    cin >> n >> t >> s;

    for(int i = 1;i <= n;i ++) cin >> a[i].l >> a[i].r;
    int ans = s;
    int sum = s;
    for(int i = 1;i <= n;i ++){
        if(a[i].l >= s) break;
        sum -= (min(s, a[i].r) - a[i].l);
    }
    ans = min(ans, sum);
    sum = s;
    for(int i = n;i >= 1;i --){
        if(a[i].r <= t - s) break;
        sum -= (a[i].r - max(a[i].l, t - s));
    }
    ans = min(ans, sum);
    int j = 1, ad = 0;
    for(int i = 1;i <= n;i ++){
        if(a[i].l > t - s) break;
        while(j < n && a[i].l + s > a[j + 1].l){
            ad += (a[j].r - a[j].l);
            j ++;
        }
        int miss = s - ad - (min(a[j].r, a[i].l + s) - a[j].l);
        ans = min(ans, miss);
        ad -= (a[i].r - a[i].l);
    }
    cout << ans << '\n';
    return 0;
}