#include <bits/stdc++.h>
using namespace std;
int n, T;
vector<int> g[111];
bool cmp(int x, int y) { return y < x; }
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) {
    int t, q;
    scanf("%d%d", &t, &q);
    g[t].push_back(q);
  }
  for (int t = 1; t <= T; t++) {
    sort(g[t].begin(), g[t].end(), cmp);
    for (int i = 0; i < g[t].size(); i += 2) {
      if (i + 1 < g[t].size())
        g[t + 1].push_back(g[t][i] + g[t][i + 1]);
      else
        g[t + 1].push_back(g[t][i]);
    }
  }
  printf("%d\n", g[T][0]);
  return 0;
}
