function main(input) {
    var args = input.trim().split("\n");
    var info = args[0].split(" ").map((v) => parseInt(v));
    var N = info[0];
    var M = info[1];
    var jobs = args.filter((v, i) => i !== 0).map((v) => {
        return v.split(" ").map(v2 => parseInt(v2));
    });

    jobs.sort((a, b) => {
        return a[1] > b[1] ? -1 : 1;
    });

    var result = 0;
    while(M !== 0 && jobs.length > 0) {
        var job = null;
        while (jobs.length > 0) {
            job = jobs.shift();
            if (job[0] > M) continue;
            result += job[1];
            break;
        }
        M--;
    }

    console.log(result);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));