#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1000;
vector<int> G[MaxN + 5];
int n, T;
int a, b;
int main() {
  while (~scanf("%d%d", &n, &T)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &a, &b);
      G[a].push_back(b);
    }
    for (int i = 1; i < T; i++) {
      sort(G[i].begin(), G[i].end());
      for (int j = G[i].size() - 1; j >= 0; j -= 2) {
        if (j > 0)
          G[i + 1].push_back(G[i][j] + G[i][j - 1]);
        else
          G[i + 1].push_back(G[i][j]);
      }
    }
    sort(G[T].begin(), G[T].end());
    printf("%d\n", G[T][G[T].size() - 1]);
  }
  return 0;
}
