#include <bits/stdc++.h>
using namespace std;
int N, T;
int dp[110][1010];
vector<int> vq[110];
int calc(int dep, int num) {
  if (dep == T || num == 0) return 0;
  if (dp[dep][num] != -1) return dp[dep][num];
  int ret = 0;
  int s = 0;
  for (int i = 0; i <= vq[T - dep].size(); ++i) {
    if (i > num) break;
    ret = max(ret, s + calc(dep + 1, min((num - i) * 2, 1000)));
    if (i < vq[T - dep].size()) s += vq[T - dep][i];
  }
  return dp[dep][num] = ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> N >> T;
  for (int i = 0; i < (N); i++) {
    int x, y;
    cin >> x >> y;
    vq[x].push_back(y);
  }
  for (int i = 1; i <= T; ++i) {
    sort((vq[i]).begin(), (vq[i]).end());
    reverse((vq[i]).begin(), (vq[i]).end());
  }
  cout << calc(0, 1) << endl;
  return 0;
}
