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