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 = (new Array(M)).fill(null);
    var day = M
    while(day !== 0 && jobs.length > 0) {
        var job = null;
        while (jobs.length > 0) {
            job = jobs.shift();
            if (job[0] > M) continue;
            var i = -1;
            while(M >= job[0] + i) {
                if (result[job[0] + i] === null) {
                    result[job[0] + i] = job[1];
                    break;
                }
                i++;
            }
            break;
        }
        day--;
    }

    var v = 0;
    for (var i = 0; result.length > i; i++) {
        v += result[i];
    }

    console.log(v);
}

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