#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll d[300010], p[300010]; 
int main() {
    int n, q;
    cin >> n >> q;

    for (int i = 1; i <= n; i++) {
        cin >> d[i] >> p[i];
    }
    ll k;
    cin >> k; 
    sort(d+1, d+n+1);
    ll u = 0;
    for (int i = 1; i <= n; i++) {
        if (d[i] <= k) {
            u += p[i];
        } else {
            break; 
        }
    }

    cout << u << endl;

    return 0;
}