#include <bits/stdc++.h>
using namespace std;
const int N = 1005, M = 105;
int n, t, a1[M][N];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
inline bool cmp(int i, int j) { return i > j; }
int main() {
  n = read(), t = read();
  memset(a1, 0, sizeof a1);
  for (int i = 1, x, w; i <= n; ++i) {
    x = read(), w = read();
    ++a1[x][0];
    a1[x][a1[x][0]] = w;
  }
  for (int i = 1; i < t; ++i) {
    sort(a1[i] + 1, a1[i] + a1[i][0] + 1, cmp);
    for (int j = 1; j <= a1[i][0]; j += 2) {
      ++a1[i + 1][0];
      a1[i + 1][a1[i + 1][0]] = a1[i][j] + a1[i][j + 1];
    }
  }
  sort(a1[t] + 1, a1[t] + a1[t][0] + 1, cmp);
  printf("%d", a1[t][1]);
  return 0;
}
