#include <bits/stdc++.h>
using namespace std;
int n, t, tt;
long long w, ans;
vector<long long> v[105];
int main() {
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%I64d", &tt, &w);
    v[tt].push_back(w);
  }
  for (int i = 1; i <= t; ++i) {
    sort(v[i].begin(), v[i].end());
    for (int j = v[i].size() - 1; j >= 0; j -= 2) {
      if (j == 0)
        v[i + 1].push_back(v[i][j]);
      else
        v[i + 1].push_back(v[i][j] + v[i][j - 1]);
    }
  }
  ans = v[t][v[t].size() - 1];
  printf("%I64d\n", ans);
  return 0;
}
