#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 3;
vector<int> a[N];
int main() {
  int i, n, T, mx, j, ti, qi;
  scanf("%d%d", &n, &T);
  for (i = 0; i < n; ++i) {
    scanf("%d%d", &ti, &qi);
    a[ti].push_back(qi);
  }
  for (i = 0; i < T; ++i) {
    sort(a[i].begin(), a[i].end());
    for (j = a[i].size() - 1; j >= 0; j -= 2) {
      if (!j)
        a[i + 1].push_back(a[i][0]);
      else
        a[i + 1].push_back(a[i][j] + a[i][j - 1]);
    }
  }
  mx = 0;
  for (i = 0; i < a[T].size(); ++i) mx = max(mx, a[T][i]);
  printf("%d\n", mx);
  return 0;
}
