#include <bits/stdc++.h>
using namespace std;
struct T {
  int a;
};
long long int bigmod(long long int a, long long int b, long long int mod) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long int hh = bigmod(a, b / 2, mod);
    return (hh * hh) % mod;
  } else {
    return (a * bigmod(a, b - 1, mod)) % mod;
  }
}
int dp[105][5050];
vector<int> ar[105];
int rec(int h, int c, int t) {
  if (h > t) return 0;
  int &ret = dp[h][c];
  if (ret != -1) return ret;
  if (c * 2 < 4000)
    ret = rec(h + 1, c * 2, t);
  else
    ret = rec(h + 1, 3000, t);
  int u = 0;
  for (int i = 0; i < ar[h].size() && i < c; i++) {
    u = u + ar[h][i];
    if ((c - i - 1) * 2 < 4000)
      ret = max(ret, u + rec(h + 1, (c - i - 1) * 2, t));
    else
      ret = max(ret, u + rec(h + 1, 3000, t));
  }
  return ret;
}
int main() {
  int i, j, k, l, t, cs = 1, r = 1, s, m, n, a, b, c, d, e, f, g, h, u, v;
  scanf("%d %d", &n, &t);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &v);
    ar[t - u].push_back(v);
  }
  memset(dp, -1, sizeof(dp));
  for (i = 0; i <= t; i++) sort(ar[i].begin(), ar[i].end(), greater<int>());
  printf("%d\n", rec(0, 1, t));
  return 0;
}
