#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-10;
const long long LINF = 1e14;
const int INF = 1e9 + 7;
const long double PI = acos(-1.0);
const int NUM = 1007;
const int NUM1 = 107;
vector<int> wws[NUM1];
int dp[NUM1][NUM];
int N;
void init() {
  for (int i = 0; i < NUM1; i++) {
    for (int j = 0; j < NUM; j++) {
      dp[i][j] = -1;
    }
  }
}
void setdp(int i, int j, int res) {
  j = min(j, N);
  dp[i][j] = max(dp[i][j], res);
}
int main() {
  srand(time(NULL));
  int n, t;
  cin >> n >> t;
  N = n;
  for (int i = 0; i < n; i++) {
    int qt, qw;
    cin >> qt >> qw;
    wws[t - qt].push_back(qw);
  }
  for (int i = 0; i <= t; i++) {
    sort(wws[i].begin(), wws[i].end());
    reverse(wws[i].begin(), wws[i].end());
  }
  init();
  int ans = 0;
  dp[0][1] = 0;
  for (int i = 0; i < t + 2; i++) {
    for (int j = 0; j <= n; j++) {
      if (dp[i][j] >= 0) {
        int qres = dp[i][j];
        ans = max(ans, dp[i][j]);
        for (int k = 0; k <= wws[i].size() && k <= j; k++) {
          setdp(i + 1, (j - k) * 2, qres);
          if (k < wws[i].size()) qres += wws[i][k];
        }
      }
    }
  }
  cout << ans;
  return 0;
}
