#include <bits/stdc++.h>
using namespace std;
priority_queue<int> dead[105];
int main() {
  ios_base::sync_with_stdio(0);
  int N, T;
  cin >> N >> T;
  for (int g = 1; g <= N; g++) {
    int t, q;
    cin >> t >> q;
    dead[T - t].push(q);
  }
  for (int g = 100; g >= 1; g--) {
    while (dead[g].size()) {
      int k = dead[g].top();
      dead[g].pop();
      if (!dead[g].size()) {
        dead[g - 1].push(k);
        continue;
      }
      k += dead[g].top();
      dead[g].pop();
      dead[g - 1].push(k);
    }
  }
  cout << dead[0].top();
  return 0;
}
