#include <bits/stdc++.h>
using namespace std;
int mread() {
  int ret = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  do {
    ret = ret * 10 + c - '0';
    c = getchar();
  } while ('0' <= c && c <= '9');
  return ret * f;
}
struct dat {
  int t, q;
  bool operator<(const dat& a) const {
    if (t == a.t) return q < a.q;
    return t > a.t;
  }
} task[2010];
priority_queue<dat> Q;
int n, T;
int main() {
  dat fir, sec;
  int mmin = 1e9, ans = -1;
  n = mread(), T = mread();
  for (int i = 1; i <= n; i++) {
    task[i].t = mread(), task[i].q = mread();
    Q.push(task[i]);
    mmin = min(mmin, task[i].t);
  }
  while (Q.top().t < T && Q.size() >= 2) {
    fir = Q.top(), Q.pop();
    sec = Q.top(), Q.pop();
    if (fir.t != sec.t) {
      fir.t++;
      Q.push(fir);
      Q.push(sec);
    } else {
      fir.q += sec.q;
      fir.t++;
      if (fir.t <= T) Q.push(fir);
    }
  }
  printf("%d\n", Q.top().q);
  return 0;
}
