#include <bits/stdc++.h>
using namespace std;
int n, t, x, y;
vector<int> g[(1 << 10)];
int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) cin >> x >> y, g[x].push_back(y);
  for (int i = 1; i <= t; i++) {
    sort(g[i].begin(), g[i].end(), greater<int>());
    for (int j = 0; j < g[i].size(); j += 2)
      if (j == g[i].size() - 1)
        g[i + 1].push_back(g[i][j]);
      else
        g[i + 1].push_back(g[i][j] + g[i][j + 1]);
  }
  cout << g[t][0] << endl;
}
