#include <bits/stdc++.h>
using namespace std;
const int mx = 110;
const long long int inf = (1 << 13);
vector<int> lyr[mx];
map<pair<int, long long int>, int> f;
int solve(int l, long long int q) {
  if (l >= mx) return 0;
  if (q == 0) return 0;
  pair<int, long long int> ky(l, q);
  if (f.count(ky) == 1) return f[ky];
  int ans = solve(l + 1, min(q << 1, inf));
  int sm = 0;
  for (int i = 0; i < int(lyr[l].size()); i++) {
    long long int rem = q - i - 1;
    if (rem < 0) break;
    sm += lyr[l][i];
    int bet = sm + solve(l + 1, min(rem << 1, inf));
    if (bet > ans) ans = bet;
  }
  f[ky] = ans;
  return ans;
}
int main() {
  int n, t, ti, qi;
  scanf("%d %d", &n, &t);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &ti, &qi);
    lyr[t - ti].push_back(qi);
  }
  for (int i = 0; i <= 30; i++) {
    sort(lyr[i].begin(), lyr[i].end(), greater<int>());
  }
  int ans = solve(0, 1);
  printf("%d\n", ans);
  return 0;
}
