#include <bits/stdc++.h>
using namespace std;
deque<int> q;
deque<int> q2;
vector<int> qs[110];
int main() {
  int n, t, tt, qq;
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &tt, &qq);
    qs[tt].push_back(qq);
  }
  for (int i = 0; i <= t; i++) sort(qs[i].begin(), qs[i].end());
  for (int i = 0; i <= t; i++) {
    if (q.size() != 0) {
      q2.clear();
      for (int j = q.size() % 2; j + 1 < q.size(); j += 2)
        q2.push_back(q[j] + q[j + 1]);
      if (q.size() % 2 != 0) q2.push_back(q.front());
      sort(q2.begin(), q2.end());
      q = q2;
    }
    for (int j = 0; j < qs[i].size(); j++) {
      q.push_back(qs[i][j]);
    }
    sort(q.begin(), q.end());
    while (t - i <= 11 && ((1 << (t - i)) < q.size())) q.pop_front();
  }
  printf("%d", q[0]);
}
