#include <bits/stdc++.h>
using namespace std;
using lld = int64_t;
const int INF = 1 << 29;
const int T = 100 + 5;
priority_queue<lld> pq[T];
inline int qPow(int, int);
inline int mul(int a, int b) {
  if (a > INF / b) return INF;
  return a * b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, t;
  cin >> n >> t;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    pq[a].push(b);
  }
  for (int i = 1; i < t; ++i) {
    int cnt = qPow(2, T - i);
    if (pq[i].size() & 1) pq[i].push(0);
    int sz = static_cast<int>(pq[i].size());
    sz = min(sz, cnt);
    for (int j = 0; j < sz; j += 2) {
      lld x = pq[i].top();
      pq[i].pop();
      lld y = pq[i].top();
      pq[i].pop();
      pq[i + 1].push(x + y);
    }
  }
  cout << pq[t].top() << '\n';
  return 0;
}
inline int qPow(int a, int k) {
  int r = 1;
  while (k) {
    if (k & 1) r = mul(r, a);
    k >>= 1;
    a = mul(a, a);
  }
  return r;
}
