#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int M = 1e9;
const int inf = 1e9 + 7;
const int base = 1e9 + 9;
const double pi = acos(-1);
const double ep = 1e-9;
vector<int> gt[102];
int n, t;
int main() {
  cin >> n >> t;
  for (int i = (int)0; i < (int)n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    gt[u].push_back(v);
  }
  for (int i = (int)1; i < (int)t; i++) {
    if (gt[i].size() == 0) continue;
    sort(gt[i].begin(), gt[i].end());
    reverse(gt[i].begin(), gt[i].end());
    for (int j = 0; j + 1 < gt[i].size(); j += 2) {
      gt[i + 1].push_back(gt[i][j] + gt[i][j + 1]);
    }
    if (gt[i].size() % 2 == 1) gt[i + 1].push_back(gt[i].back());
  }
  if (gt[t].size() == 0)
    cout << 0;
  else {
    sort(gt[t].begin(), gt[t].end());
    cout << gt[t].back();
  }
}
