#include <bits/stdc++.h>
using namespace std;
const int N = 1005, T = 105;
int n, t;
vector<int> tasks[T];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> t;
  for (int i = 1; i <= n; ++i) {
    int a, b;
    cin >> a >> b;
    tasks[a].emplace_back(b);
  }
  for (int i = 1; i <= t; ++i) {
    sort(tasks[i].begin(), tasks[i].end(), greater<int>());
    for (int j = 0; j < tasks[i].size(); j += 2) {
      if (j + 1 < tasks[i].size())
        tasks[i + 1].emplace_back(tasks[i][j] + tasks[i][j + 1]);
      else
        tasks[i + 1].emplace_back(tasks[i][j]);
    }
  }
  cout << tasks[t][0] << endl;
  return 0;
}
