#include <bits/stdc++.h>
using namespace std;
int n,q,d[300005],p[300005],k,brp,br;
int main () {

cin>>n>>q;
for (int i=1;i<=n;i++) {
  cin>>d[i]>>p[i];
}
cin>>k;
brp=p[1];
for (int i=d[1];i<=k;i++) {
  if (d[2]==i) {brp=brp+p[2];}
  if (d[3]==i) {brp=brp+p[3];}
  if (brp>0) {brp--;br++;}
}
cout<<br<<endl;
return 0;
}