#include <bits/stdc++.h>
using namespace std;
const int Max = 1111;
long long n, T;
long long t[Max], q[Max];
vector<long long> ans[Max];
int main() {
  cin >> n >> T;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> q[i];
    ans[T - t[i]].push_back(q[i]);
  }
  for (int i = Max - 1; i > 0; i--) {
    sort(ans[i].begin(), ans[i].end());
    while (true) {
      if (ans[i].size() == 0) break;
      if (ans[i].size() == 1) {
        ans[i - 1].push_back(ans[i][0]);
        ans[i].pop_back();
      } else {
        long long B = ans[i][ans[i].size() - 1];
        long long A = ans[i][ans[i].size() - 2];
        ans[i - 1].push_back(A + B);
        ans[i].pop_back();
        ans[i].pop_back();
      }
    }
  }
  sort(ans[0].begin(), ans[0].end());
  cout << ans[0][ans[0].size() - 1] << endl;
  return 0;
}
