#include <bits/stdc++.h>
using namespace std;
const int M = 1010;
int n, T;
vector<int> q[101];
int dp[101][1010];
int dfs(int pos, int remain) {
  if (pos == T) return 0;
  int& x = dp[pos][remain];
  if (x != -1) return x;
  x = 0;
  for (int i = 0; i < q[pos].size() && i <= remain; i++) {
    x = max(x, q[pos][i] + dfs(pos + 1, min(n, (remain - i) * 2)));
  }
  return x;
}
int main() {
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x <= T) {
      q[T - x].push_back(y);
    }
  }
  for (int i = 0; i < T; i++) {
    if (q[i].size() > 0) sort(q[i].begin(), q[i].end(), greater<int>());
    q[i].insert(q[i].begin(), 0);
    for (int j = 1; j < q[i].size(); j++) {
      q[i][j] += q[i][j - 1];
    }
  }
  memset(dp, -1, sizeof dp);
  int ans = dfs(0, 1);
  printf("%d\n", ans);
}
