#include <bits/stdc++.h>
using namespace std;
struct node {
  int k, val;
} e[2222];
bool cmp(node a, node b) {
  if (a.k != b.k) return a.k < b.k;
  return a.val > b.val;
}
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) scanf("%d%d", &e[i].k, &e[i].val);
  int ans = 0;
  while (1) {
    sort(e + 1, e + 1 + n, cmp);
    if (e[1].k > T) break;
    if (e[1].val > ans) ans = e[1].val;
    if (e[1].k != e[2].k) {
      e[1].k = e[2].k;
      continue;
    }
    e[1].k += 1;
    e[2].k = 9999999;
    e[1].val += e[2].val;
  }
  printf("%d\n", ans);
}
