#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10;
struct Task {
  int t, q;
  int operator<(const Task &that) const { return t < that.t; }
} a[N];
vector<int> b, c;
int n, maxT;
int main() {
  cin >> n >> maxT;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].t >> a[i].q;
  }
  for (int dep = maxT - 1; dep >= 0; --dep) {
    for (int i = 0; i < n; ++i) {
      if (a[i].t + dep == maxT) {
        b.push_back(-a[i].q);
      }
    }
    sort(b.begin(), b.end());
    if (dep < 30) {
      for (; b.size() > (1 << dep); b.pop_back())
        ;
    }
    if (b.size() % 2 == 1) {
      b.push_back(0);
    }
    c.clear();
    for (int i = 0; i < b.size(); i += 2) {
      c.push_back(b[i] + b[i + 1]);
    }
    b = c;
  }
  cout << -b[0] << endl;
  return 0;
}
