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