#include <bits/stdc++.h>
using namespace std;
void reloc() { freopen("cards.in", "r", stdin); }
const int maxn = 1000, maxt = 101;
int n, t;
vector<int> a[maxt + 1];
void read() {
  int ti, qi;
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &ti, &qi);
    a[ti].push_back(qi);
  }
}
void combine(int i) {
  sort(a[i].begin(), a[i].end());
  for (int j = (int)a[i].size() - 1; j >= 0; j -= 2) {
    if (j != 0) {
      a[i + 1].push_back(a[i][j] + a[i][j - 1]);
    } else
      a[i + 1].push_back(a[i][j]);
  }
}
void work() {
  for (int i = 1; i <= t - 1; i++) {
    combine(i);
  }
  sort(a[t].begin(), a[t].end());
  printf("%d\n", a[t][a[t].size() - 1]);
}
int main() {
  read();
  work();
  return 0;
}
