#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
const int T = 105;
struct p {
  int t, q;
  p() {}
  p(int a, int b) {
    t = a;
    q = b;
  }
};
bool cmp(p a, p b) {
  if (a.t != b.t) return a.t < b.t;
  return a.q > b.q;
}
int n, t;
p task[N];
int f[T][N];
int cnt[T], pre[T][N];
int ans;
void cmax(int &a, int b) {
  if (b > a) a = b;
}
int main() {
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; i++) scanf("%d%d", &task[i].t, &task[i].q);
  sort(task + 1, task + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    cnt[task[i].t]++;
    pre[task[i].t][cnt[task[i].t]] =
        pre[task[i].t][cnt[task[i].t] - 1] + task[i].q;
  }
  memset(f, -1, sizeof(f));
  f[0][1] = 0;
  for (int i = 0; i < t; i++) {
    cmax(ans, f[i][0]);
    for (int j = 1; j <= n; j++)
      if (f[i][j] != -1)
        for (int k = 0; k <= min(j, cnt[t - i]); k++)
          cmax(f[i + 1][min(n, 2 * (j - k))], f[i][j] + pre[t - i][k]);
  }
  for (int i = 0; i <= n; i++) cmax(ans, f[t][i]);
  printf("%d\n", ans);
  return 0;
}
