#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
const int maxT = 100;
int n, T;
vector<int> level[maxT + 1];
void read();
void debug(int);
int main() {
  read();
  for (int i = 1; i < T; i++) {
    debug(i);
    if (level[i].empty()) continue;
    sort(level[i].begin(), level[i].end());
    for (int j = level[i].size() - 1; j > 0; j -= 2) {
      int newValue = level[i][j] + level[i][j - 1];
      level[i + 1].push_back(newValue);
    }
    if (level[i].size() % 2 == 1) level[i + 1].push_back(level[i][0]);
  }
  sort(level[T].begin(), level[T].end());
  cout << level[T][level[T].size() - 1] << endl;
  return 0;
}
void read() {
  cin >> n >> T;
  for (int i = 0; i < n; i++) {
    int time, value;
    cin >> time >> value;
    level[time].push_back(value);
  }
}
void debug(int ind) {
  cerr << "Level " << ind << ":";
  for (int i = 0; i < level[ind].size(); i++) cerr << ' ' << level[ind][i];
  cerr << endl;
}
